Commit 6eff25cb authored by Enrico Zini's avatar Enrico Zini

Updated summarize-json-dumps to load v1 dumps [skip ci]

parent ba7cf489
Pipeline #76135 skipped
......@@ -55,6 +55,7 @@ class Summary:
dt = datetime.datetime.strptime(fn, "%Y%m%d-%H%M%S-db-full.json")
else:
log.error("%s: unrecognised file name", fn)
continue
log.debug("Found %s", dt)
dt = dt.strftime("%Y%m%d%H%M%S")
......@@ -107,6 +108,36 @@ class Summary:
log.info("%s: %d new, %d updated, %d unchanged %d removed", fn, new, updated, unchanged, removed)
def add_dump_v1(self, fn, dt, data):
new = 0
updated = 0
unchanged = 0
keys_found = set()
for person in data["people"]:
key = person["lookup_key"]
keys_found.add(key)
history = self.people.get(key)
if history is None:
new += 1
self.people[key] = [(dt, person)]
elif history[-1][0] > dt:
log.warn("%s: last seen for %s is from %s but found earlier %s: skipped", fn, key, history[-1][0], dt)
elif history[-1][1] != person:
updated += 1
history.append((dt, person))
else:
unchanged += 1
removed = 0
for key in self.people.keys() - keys_found:
history = self.people.get(key)
if history[-1][1] is not None:
history.append((dt, None))
removed += 1
log.info("%s: %d new, %d updated, %d unchanged %d removed", fn, new, updated, unchanged, removed)
def print_history(self, key):
try:
from jsondiff import JsonDiffer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment