1
0
mirror of http://git.k-space.ee/arti/doors.git synced 2024-11-12 15:30:59 +02:00

Also export keycard creation date from ookean

This commit is contained in:
Arti Zirk 2020-10-01 21:49:46 +03:00
parent cf7342035d
commit de8af3cb0d

View File

@ -7,7 +7,7 @@ db = _mysql.connect(host="localhost", db="ookean",
user="root", passwd="salakala") user="root", passwd="salakala")
db.query(""" db.query("""
select persons.name, t2.uid, t2.name from persons join tagowners t on persons.id = t.person_id join tags t2 on t.tag_id = t2.id select persons.name, t2.uid, t2.name, t2.create_date from persons join tagowners t on persons.id = t.person_id join tags t2 on t.tag_id = t2.id
where persons.archived is null and t.revoked_date is null and t2.archived is null; where persons.archived is null and t.revoked_date is null and t2.archived is null;
""") """)
r=db.store_result() r=db.store_result()
@ -26,16 +26,16 @@ nicknames = {
cards = defaultdict(list) cards = defaultdict(list)
for x in range(r.num_rows()): for x in range(r.num_rows()):
name, uid, descr = r.fetch_row()[0] name, uid, descr, create_date = r.fetch_row()[0]
name, uid, descr = name.decode(), uid.decode(), descr.decode() if descr else descr name, uid, descr, create_date = name.decode(), uid.decode(), descr.decode() if descr else descr, create_date.decode()
name = name.replace("(deactivated)", "")\ name = name.replace("(deactivated)", "")\
.replace("(Deactivated)","").replace("(Paused)", "").replace("(disactive)", "")\ .replace("(Deactivated)","").replace("(Paused)", "").replace("(disactive)", "")\
.replace("(Disabled)", "").replace("(Protoskoop)", "")\ .replace("(Disabled)", "").replace("(Protoskoop)", "")\
.strip() .strip()
if name in nicknames: if name in nicknames:
name = nicknames[name] name = nicknames[name]
cards[name].append({"uid": uid, "descr": descr}) cards[name].append({"uid": uid, "descr": descr, "create_date":str(create_date)})
print(f"{name:30} {uid:20} {descr}") print(f"{name:30} {uid:20} {str(create_date)} {descr}")
with open("ookean_cards.json", "w") as fp: with open("ookean_cards.json", "w") as fp:
json.dump(cards, fp, indent=2) json.dump(cards, fp, indent=2)