udpated updater for News 15

This commit is contained in:
Gwenhael Le Moine 2020-10-01 10:31:50 +02:00
parent 2a9b9ca150
commit 069a015f7b
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -12,16 +12,22 @@ end
occ( 'news:updater:before-update' )
feeds = JSON.parse( occ( 'news:updater:all-feeds' ) )["feeds"]
users = JSON.parse( occ( 'user:list --output=json' ) )
slices_size = (feeds.length / NB_THREADS).floor
users.keys.each do |userId|
feeds = JSON.parse( occ( "news:feed:list #{userId}" ) )
ThreadsWait.all_waits( feeds.each_slice( slices_size ).to_a.map do |subfeeds|
Thread.new do
subfeeds.each do |feed|
occ( "news:updater:update-feed #{feed['id']} #{feed['userId']}" )
next if feeds.empty?
slices_size = (feeds.length / NB_THREADS).floor
ThreadsWait.all_waits( feeds.each_slice( slices_size ).to_a.map do |subfeeds|
Thread.new do
subfeeds.each do |feed|
occ( "news:updater:update-feed #{userId} #{feed['id']}" )
end
end
end
end )
end )
end
occ( 'news:updater:after-update' )