v55: fix item_count to query actual DB count
This commit is contained in:
+6
-5
@@ -163,13 +163,14 @@ func (c *Crawler) handleAPIDomains(w http.ResponseWriter, r *http.Request) {
|
||||
hosts = append(hosts, d.Host)
|
||||
}
|
||||
|
||||
// Now get feeds for these domains
|
||||
// Now get feeds for these domains (with actual item count from items table)
|
||||
if len(hosts) > 0 {
|
||||
feedRows, err := c.db.Query(`
|
||||
SELECT source_host, url, title, type, status, publish_status, language, item_count
|
||||
FROM feeds
|
||||
WHERE source_host = ANY($1)
|
||||
ORDER BY source_host, url
|
||||
SELECT f.source_host, f.url, f.title, f.type, f.status, f.publish_status, f.language,
|
||||
(SELECT COUNT(*) FROM items WHERE feed_url = f.url) as item_count
|
||||
FROM feeds f
|
||||
WHERE f.source_host = ANY($1)
|
||||
ORDER BY f.source_host, f.url
|
||||
`, hosts)
|
||||
if err == nil {
|
||||
defer feedRows.Close()
|
||||
|
||||
+2
-1
@@ -58,7 +58,8 @@ func (c *Crawler) handleAPIFeedInfo(w http.ResponseWriter, r *http.Request) {
|
||||
discovered_at, last_crawled_at, next_crawl_at, last_build_date,
|
||||
ttl_minutes, update_period, update_freq,
|
||||
status, error_count, last_error,
|
||||
item_count, avg_post_freq_hrs, oldest_item_date, newest_item_date,
|
||||
(SELECT COUNT(*) FROM items WHERE feed_url = feeds.url) as item_count,
|
||||
avg_post_freq_hrs, oldest_item_date, newest_item_date,
|
||||
publish_status, publish_account
|
||||
FROM feeds WHERE url = $1
|
||||
`, feedURL).Scan(
|
||||
|
||||
+1
-1
@@ -534,7 +534,7 @@ const dashboardHTML = `<!DOCTYPE html>
|
||||
<div id="output"></div>
|
||||
</div>
|
||||
|
||||
<div style="color: #333; font-size: 11px; margin-top: 10px;">v54</div>
|
||||
<div style="color: #333; font-size: 11px; margin-top: 10px;">v55</div>
|
||||
|
||||
<div class="updated" id="updatedAt">Last updated: {{.UpdatedAt.Format "2006-01-02 15:04:05"}}</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user