2018-03-14 14:35:32 +01:00
|
|
|
#!/usr/bin/env ruby
|
2019-12-27 18:10:01 +01:00
|
|
|
# frozen_string_literal true
|
2018-03-14 14:35:32 +01:00
|
|
|
require "json"
|
2019-12-27 18:10:01 +01:00
|
|
|
require "thwait" # gem install e2mmap thwait
|
2018-03-14 14:35:32 +01:00
|
|
|
|
2018-08-28 15:47:36 +02:00
|
|
|
NC_ROOT = "/srv/www/vhosts/nextcloud-server/htdocs".freeze
|
|
|
|
NB_THREADS = 2
|
2018-03-14 14:35:32 +01:00
|
|
|
|
|
|
|
def occ( command )
|
|
|
|
`php -f #{NC_ROOT}/occ #{command}`
|
|
|
|
end
|
|
|
|
|
|
|
|
occ( 'news:updater:before-update' )
|
|
|
|
|
2018-08-28 15:47:36 +02:00
|
|
|
feeds = JSON.parse( occ( 'news:updater:all-feeds' ) )["feeds"]
|
|
|
|
|
|
|
|
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 #{feed['id']} #{feed['userId']}" )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end )
|
2018-03-14 14:35:32 +01:00
|
|
|
|
|
|
|
occ( 'news:updater:after-update' )
|