fbe 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fbe/iterate.rb +18 -9
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_iterate.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8717c1012de84a6572ddc133f271a1079a0f58a269e30b5a3179a46082bb2b7a
|
4
|
+
data.tar.gz: 9003717ff372d2e001f31470c29e5ae35468e6b249c3bc24c6d09a1126e0c197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
@
|
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
|
56
|
-
raise 'Cannot set "
|
57
|
-
|
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]
|
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
|
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 < @
|
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
data/test/fbe/test_iterate.rb
CHANGED