mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
Create views if they don't exist
This commit is contained in:
parent
0a404cc9a6
commit
4865529fed
1 changed files with 10 additions and 1 deletions
|
@ -131,7 +131,16 @@ 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
|
||||||
logger.write("REFRESH #{email} : #{ex.message}\n")
|
# 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")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
active_channel.send(true)
|
active_channel.send(true)
|
||||||
|
|
Loading…
Reference in a new issue