diff --git a/crawl-rss/main.go b/crawl-rss/main.go index 008a0ba..17bc2fc 100644 --- a/crawl-rss/main.go +++ b/crawl-rss/main.go @@ -27,10 +27,16 @@ func main() { for _, torrent := range torrents { addTorrent(db, torrent, &crawled) } - time.Sleep(time.Minute * 30) + time.Sleep(time.Minute * 45) + go refresh(db) } } +func refresh(db *sql.DB) { + db.Exec("REFRESH MATERIALIZED VIEW fresh") + db.Exec("REFRESH MATERIALIZED VIEW CONCURRENTLY search") +} + func addTorrent(db *sql.DB, torr Torrent, crawled *map[string]bool) { if !(*crawled)[string(torr.Infohash)] { _, err := db.Exec("INSERT INTO torrent (infohash, name, length) VALUES ($1, $2, $3)", torr.Infohash, torr.Name, torr.Length)