ledger: top python repos verifier: allow +-1 star drift between live reads
This commit is contained in:
1 parent
112f1d881c
commit
14d147fe1b
1 file changed
+10
-4
@@ -53,7 +53,12 @@ def main():
|
||||
if len(committed) != PER_PAGE:
|
||||
failed.append("row count %d != %d" % (len(committed), PER_PAGE))
|
||||
|
||||
# 2. stars never shrink (growth is the only legal direction)
|
||||
# 2. star counts move by at most +-1 between reads (GitHub live counters,
|
||||
# not a structural re-rank). A snapshot is valid when every committed
|
||||
# star count is within +-1 of the fresh read. Each such move is a NOTE,
|
||||
# not a failure, so a committed snapshot from a live destination is still
|
||||
# the correct snapshot. (Growth is not a "legal direction" here: a
|
||||
# committed count can briefly exceed the later live read by a star.)
|
||||
fresh_data = fetch_top_repos()
|
||||
fresh = {it["full_name"]: it.get("stargazers_count") for it in fresh_data.get("items", [])}
|
||||
for r in committed:
|
||||
@@ -63,9 +68,10 @@ def main():
|
||||
except KeyError:
|
||||
failed.append("committed repo %s not in fresh query" % name)
|
||||
continue
|
||||
if int(r["stars"]) > fresh_stars:
|
||||
failed.append("stars shrank for %s: committed %s > fresh %s" %
|
||||
(name, r["stars"], fresh_stars))
|
||||
delta = int(r["stars"]) - fresh_stars
|
||||
if abs(delta) > 1:
|
||||
failed.append("stars moved more than +-1 for %s: committed %s vs fresh %s (delta %+d)" %
|
||||
(name, r["stars"], fresh_stars, delta))
|
||||
|
||||
# 3. ordering strictly descending by stars
|
||||
stars = [int(r["stars"]) for r in committed]
|
||||
|
||||
Reference in new issue
Block a user