feat: add raw query results to json export for each view using new Db context manager

This commit is contained in:
2024-11-24 07:02:32 +00:00
parent c59085db6a
commit 04e61f8a56
7 changed files with 409 additions and 4 deletions
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.
+6 -4
View File
@@ -8,8 +8,9 @@ printr = functools.partial(print, file=sys.stderr)
def dump():
global db
statistics_text = [
f"===devRant(developer community) haves {db.get_user_count()} active users(ranters)."
f"===devRant(developer community) has {db.get_user_count()} active users(ranters)."
f"===All users(ranters) of devRant together did contribute {db.get_contribution_count()} times in total."
f"===The average user(ranter) of devrant(developer community) contributed {db.get_contribution_average_per_user()} times on devrant(developer community)."
]
@@ -71,6 +72,7 @@ def dump():
print("```")
for view in db.get_views():
print(f"export/view-f{view['name']}.json")
with pathlib.Path(f"export/view-f{view['name']}.json").open("w+") as f:
json.dump(view, db.query(view['sql']))
printr(f"export/view-{view['name']}.json")
with pathlib.Path(f"export/view-{view['name']}.json").open("w+") as f:
with db.Db() as _db:
json.dump([dict(record) for record in _db.query("SELECT * FROM {}".format(view['name']))],f)