|
|
@ -131,8 +131,17 @@ def refresh_feeds(db, logger, max_threads = 1)
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
db.exec("REFRESH MATERIALIZED VIEW #{view_name}")
|
|
|
|
db.exec("REFRESH MATERIALIZED VIEW #{view_name}")
|
|
|
|
rescue ex
|
|
|
|
rescue ex
|
|
|
|
|
|
|
|
# Create view if it doesn't exist
|
|
|
|
|
|
|
|
if ex.message.try &.ends_with? "does not exist"
|
|
|
|
|
|
|
|
PG_DB.exec("CREATE MATERIALIZED VIEW #{view_name} AS \
|
|
|
|
|
|
|
|
SELECT * FROM channel_videos WHERE \
|
|
|
|
|
|
|
|
ucid = ANY ((SELECT subscriptions FROM users WHERE email = E'#{email.gsub("'", "\\'")}')::text[]) \
|
|
|
|
|
|
|
|
ORDER BY published DESC;")
|
|
|
|
|
|
|
|
logger.write("CREATE #{view_name}")
|
|
|
|
|
|
|
|
else
|
|
|
|
logger.write("REFRESH #{email} : #{ex.message}\n")
|
|
|
|
logger.write("REFRESH #{email} : #{ex.message}\n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
active_channel.send(true)
|
|
|
|
active_channel.send(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|