Add automatic DB index refresh to crawl-rss

Since this is the only service that runs a simple timer, I decided
to add it there.
pull/27/head
Urban Guacamole 4 years ago
parent 899086d02b
commit 26a2d1a2ad

@ -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)

Loading…
Cancel
Save