mirror of
https://gitea.invidious.io/iv-org/invidious
synced 2024-12-26 16:53:45 +01:00
Add job for pulling popular videos
This commit is contained in:
parent
26eb59e00d
commit
3c98601f35
@ -14,7 +14,6 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
require "crypto/bcrypt/password"
|
|
||||||
require "detect_language"
|
require "detect_language"
|
||||||
require "digest/md5"
|
require "digest/md5"
|
||||||
require "kemal"
|
require "kemal"
|
||||||
@ -112,6 +111,13 @@ spawn do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
popular_videos = [] of ChannelVideo
|
||||||
|
spawn do
|
||||||
|
pull_popular_videos(PG_DB) do |videos|
|
||||||
|
popular_videos = videos
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
decrypt_function = [] of {name: String, value: Int32}
|
decrypt_function = [] of {name: String, value: Int32}
|
||||||
spawn do
|
spawn do
|
||||||
update_decrypt_function do |function|
|
update_decrypt_function do |function|
|
||||||
|
@ -180,6 +180,21 @@ def pull_top_videos(config, db)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pull_popular_videos(db)
|
||||||
|
loop do
|
||||||
|
subscriptions = PG_DB.query_all("SELECT channel FROM \
|
||||||
|
(SELECT UNNEST(subscriptions) AS channel FROM users) AS d \
|
||||||
|
GROUP BY channel ORDER BY COUNT(channel) DESC LIMIT 40", as: String)
|
||||||
|
|
||||||
|
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM \
|
||||||
|
channel_videos WHERE ucid IN (#{arg_array(subscriptions)}) \
|
||||||
|
ORDER BY ucid, published DESC", subscriptions, as: ChannelVideo).sort_by { |video| video.published }.reverse
|
||||||
|
|
||||||
|
yield videos
|
||||||
|
Fiber.yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update_decrypt_function
|
def update_decrypt_function
|
||||||
loop do
|
loop do
|
||||||
begin
|
begin
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require "crypto/bcrypt/password"
|
||||||
|
|
||||||
class User
|
class User
|
||||||
module PreferencesConverter
|
module PreferencesConverter
|
||||||
def self.from_rs(rs)
|
def self.from_rs(rs)
|
||||||
|
Loading…
Reference in New Issue
Block a user