Skip to content

Commit

Permalink
#412: incremate
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 19, 2024
1 parent f91be5e commit 2afba57
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 51 deletions.
20 changes: 3 additions & 17 deletions judges/dimensions-of-terrain/dimensions-of-terrain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

require 'time'
require 'fbe/fb'
require 'fbe/octo'
require 'fbe/overwrite'
require_relative '../../lib/incremate'

f = Fbe.fb.query(
"(and
Expand All @@ -37,18 +37,4 @@
f.when = Time.now
end

start = Time.now
Dir[File.join(__dir__, 'total_*.rb')].each do |rb|
n = File.basename(rb).gsub(/\.rb$/, '')
next unless f[n].nil?
if Fbe.octo.off_quota
$loog.info('No GitHub quota left, it is time to stop')
break
end
if Time.now - start > 5 * 60
$loog.info('We are doing this for too long, time to stop')
break
end
require_relative rb
send(n, f).each { |k, v| f = Fbe.overwrite(f, k.to_s, v) }
end
Jp.incremate(f, __dir__, 'total')
19 changes: 2 additions & 17 deletions judges/quality-of-service/quality-of-service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

require 'fbe/octo'
require 'fbe/overwrite'
require 'fbe/regularly'
require_relative '../../lib/incremate'

start = Time.now
Fbe.regularly('quality', 'qos_interval', 'qos_days') do |f|
Dir[File.join(__dir__, 'average_*.rb')].each do |rb|
n = File.basename(rb).gsub(/\.rb$/, '')
next unless f[n].nil?
if Fbe.octo.off_quota
$loog.info('No GitHub quota left, it is time to stop')
break
end
if Time.now - start > 5 * 60
$loog.info('We are doing this for too long, time to stop')
break
end
require_relative rb
send(n, f).each { |k, v| f = Fbe.overwrite(f, k.to_s, v) }
end
Jp.incremate(f, __dir__, 'average')
end
19 changes: 2 additions & 17 deletions judges/quantity-of-deliverables/quantity-of-deliverables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,9 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

require 'fbe/overwrite'
require 'fbe/octo'
require 'fbe/regularly'
require_relative '../../lib/incremate'

start = Time.now
Fbe.regularly('scope', 'qod_interval', 'qod_days') do |f|
Dir[File.join(__dir__, 'total_*.rb')].each do |rb|
n = File.basename(rb).gsub(/\.rb$/, '')
next unless f[n].nil?
if Fbe.octo.off_quota
$loog.info('No GitHub quota left, it is time to stop')
break
end
if Time.now - start > 5 * 60
$loog.info('We are doing this for too long, time to stop')
break
end
require_relative rb
send(n, f).each { |k, v| f = Fbe.overwrite(f, k.to_s, v) }
end
Jp.incremate(f, __dir__, 'total')
end
47 changes: 47 additions & 0 deletions lib/incremate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

# MIT License
#
# Copyright (c) 2024 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

require 'fbe/octo'
require 'fbe/overwrite'
require_relative 'jp'

# Incrementaly accumulates data into a fact, using Ruby scripts
# found in the directory provided, by the prefix.
def Jp.incremate(fact, dir, prefix)
start = Time.now
Dir[File.join(dir, "#{prefix}_*.rb")].each do |rb|
n = File.basename(rb).gsub(/\.rb$/, '')
next unless fact[n].nil?
if Fbe.octo.off_quota
$loog.info('No GitHub quota left, it is time to stop')
break
end
if Time.now - start > 5 * 60
$loog.info('We are doing this for too long, time to stop')
break
end
require_relative rb
send(n, fact).each { |k, v| fact = Fbe.overwrite(fact, k.to_s, v) }
end
end
26 changes: 26 additions & 0 deletions lib/jp.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

# MIT License
#
# Copyright (c) 2024 Zerocracy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# The module with supplementary features.
module Jp; end

0 comments on commit 2afba57

Please sign in to comment.