slackbuilds/n/nextcloud-server/nextcloud-news-updater.rb
Gwenhael Le Moine 01c831ab45
ruby 2.7
Signed-off-by: Gwenhael Le Moine <gwenhael.le.moine@gmail.com>
2019-12-27 18:10:01 +01:00

27 lines
799 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal true
require "json"
require "thwait" # gem install e2mmap thwait
NC_ROOT = "/srv/www/vhosts/nextcloud-server/htdocs".freeze
NB_THREADS = 2
def occ( command )
`php -f #{NC_ROOT}/occ #{command}`
end
occ( 'news:updater:before-update' )
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 )
occ( 'news:updater:after-update' )