diff --git a/api_domains.go b/api_domains.go index 1c783f7..474df22 100644 --- a/api_domains.go +++ b/api_domains.go @@ -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() diff --git a/api_feeds.go b/api_feeds.go index 770cd64..f6f0db2 100644 --- a/api_feeds.go +++ b/api_feeds.go @@ -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( diff --git a/templates.go b/templates.go index 726128c..b191285 100644 --- a/templates.go +++ b/templates.go @@ -534,7 +534,7 @@ const dashboardHTML = `
-