mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Use materialized views for subscription feeds
This commit is contained in:
parent
3fe4547f8e
commit
35e63fa3f5
5 changed files with 61 additions and 30 deletions
|
@ -15,6 +15,7 @@ class Config
|
|||
hmac_key: String?,
|
||||
full_refresh: Bool,
|
||||
geo_bypass: Bool,
|
||||
update_feeds: Bool,
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
@ -238,3 +238,9 @@ def write_var_int(value : Int)
|
|||
|
||||
return bytes
|
||||
end
|
||||
|
||||
def sha256(text)
|
||||
digest = OpenSSL::Digest.new("SHA256")
|
||||
digest << text
|
||||
return digest.hexdigest
|
||||
end
|
||||
|
|
|
@ -104,6 +104,17 @@ def refresh_videos(db)
|
|||
end
|
||||
end
|
||||
|
||||
def update_feeds(db)
|
||||
loop do
|
||||
users = db.query_all("SELECT email FROM users", as: String)
|
||||
|
||||
users.each do |email|
|
||||
view_name = "subscriptions_#{sha256(email)[0..7]}"
|
||||
db.exec("REFRESH MATERIALIZED VIEW #{view_name}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pull_top_videos(config, db)
|
||||
if config.dl_api_key
|
||||
DetectLanguage.configure do |dl_config|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue