fbe 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0081d0ed95bf4d88cc396b55651521cf252d5a7894c93e5942a4f44f902a3bd
4
- data.tar.gz: b9624f277446d361ac46b2e89d04e4b8b4a20c93adfa8c2f5b0452febde43b7b
3
+ metadata.gz: 8717c1012de84a6572ddc133f271a1079a0f58a269e30b5a3179a46082bb2b7a
4
+ data.tar.gz: 9003717ff372d2e001f31470c29e5ae35468e6b249c3bc24c6d09a1126e0c197
5
5
  SHA512:
6
- metadata.gz: 92fd51fff1c6f6347bfe1a89caa2e94bca3277c963ccaf4cce54b33144e1a38f6e060f771e8cab07503d064f1a1c4cbae47cbd5faca2ac338b6240e8308d3aff
7
- data.tar.gz: 3e03f00ef4d1c127aa021c89a72ec3f8b273b43fe2bef85bc944063e52ae0fb77a4f93d8883b6c4855852b5f67c067ffd37be04bc7b1b73cc70b454d8e295a94
6
+ metadata.gz: 60e9ecf02ca745e76c0a27f5997f054dd7b8f319fdabe9cbfd8ce809703e216ed83b316d6fc555bc66c3efea7b0da210b65f9eda650d8cb084dfc3c2614af94d
7
+ data.tar.gz: ea0b9301d932883f0507d067c8f9a730f1afa4e983e58544c86e3f35fc93e47f1b42474c5275c7372d662c850414de2075455315b7250e32c85afe35c32ed721
data/lib/fbe/iterate.rb CHANGED
@@ -44,7 +44,7 @@ class Fbe::Iterate
44
44
  @label = nil
45
45
  @since = 0
46
46
  @query = nil
47
- @limit = 100
47
+ @repeats = 1
48
48
  @quota_aware = false
49
49
  end
50
50
 
@@ -52,9 +52,10 @@ class Fbe::Iterate
52
52
  @quota_aware = true
53
53
  end
54
54
 
55
- def limit(limit)
56
- raise 'Cannot set "limit" to nil' if limit.nil?
57
- @limit = limit
55
+ def repeats(repeats)
56
+ raise 'Cannot set "repeats" to nil' if repeats.nil?
57
+ raise 'The "repeats" must be a positive integer' unless repeats.positive?
58
+ @repeats = repeats
58
59
  end
59
60
 
60
61
  def by(query)
@@ -69,16 +70,23 @@ class Fbe::Iterate
69
70
  @label = label
70
71
  end
71
72
 
73
+ # It makes a number of repeats of going through all repositories
74
+ # provided by the "repositories" configuration option. In each "repeat"
75
+ # it yields the repository ID and a number that is retrieved by the
76
+ # "query". The query is supplied with two parameter:
77
+ # "$before" (the value from the previous repeat and "$rid" (the repo ID).
72
78
  def over(&)
73
79
  raise 'Use "as" first' if @label.nil?
74
80
  raise 'Use "by" first' if @query.nil?
75
81
  seen = {}
76
82
  oct = Fbe.octo(loog: @loog)
77
83
  repos = Fbe.unmask_repos(loog: @loog)
84
+ restarted = []
78
85
  loop do
79
86
  repos.each do |repo|
87
+ next if restarted.include?(repo)
80
88
  seen[repo] = 0 if seen[repo].nil?
81
- if seen[repo] > @limit
89
+ if seen[repo] >= @repeats
82
90
  @loog.debug("We've seen too many in the #{repo} repo, time to move to the next one")
83
91
  next
84
92
  end
@@ -87,11 +95,12 @@ class Fbe::Iterate
87
95
  "(agg (and (eq what '#{@label}') (eq where 'github') (eq repository #{rid})) (first latest))"
88
96
  ).one
89
97
  Fbe.fb.query("(and (eq what '#{@label}') (eq where 'github') (eq repository #{rid}))").delete!
90
- before = before.nil? ? @since : before[0]
98
+ before = before.nil? ? @since : before.first
91
99
  nxt = Fbe.fb.query(@query).one(before:, repository: rid)
92
100
  after =
93
101
  if nxt.nil?
94
102
  @loog.debug("Next is nil, starting from the beginning at #{@since}")
103
+ restarted << repo
95
104
  @since
96
105
  else
97
106
  @loog.debug("Next is #{nxt}, starting from it...")
@@ -103,10 +112,10 @@ class Fbe::Iterate
103
112
  f.repository = rid
104
113
  f.latest =
105
114
  if after.nil?
106
- @loog.debug("After is nil, setting the `latest` to nxt: #{nxt}")
115
+ @loog.debug("After is nil at #{repo}, setting the `latest` to nxt: #{nxt}")
107
116
  nxt
108
117
  else
109
- @loog.debug("After is #{after}, setting the `latest` to it")
118
+ @loog.debug("After is #{after} at #{repo}, setting the `latest` to it")
110
119
  after
111
120
  end
112
121
  f.what = @label
@@ -120,7 +129,7 @@ class Fbe::Iterate
120
129
  @loog.debug('We are off GitHub quota, time to stop')
121
130
  break
122
131
  end
123
- unless seen.values.any? { |v| v < @limit }
132
+ unless seen.values.any? { |v| v < @repeats }
124
133
  @loog.debug('No more repos to scan, quitting')
125
134
  break
126
135
  end
data/lib/fbe.rb CHANGED
@@ -27,5 +27,5 @@
27
27
  # License:: MIT
28
28
  module Fbe
29
29
  # Current version of the gem (changed by .rultor.yml on every release)
30
- VERSION = '0.0.7'
30
+ VERSION = '0.0.8'
31
31
  end
@@ -41,7 +41,7 @@ class TestIterate < Minitest::Test
41
41
  Fbe.iterate($fb, Loog::NULL) do
42
42
  as 'labels-were-scanned'
43
43
  by '(agg (always) (max foo))'
44
- limit 2
44
+ repeats 2
45
45
  over do |_repository, foo|
46
46
  f = $fb.insert
47
47
  f.foo = foo + 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko