Added event data export

This commit is contained in:
2023-04-14 13:24:20 +02:00
parent 9a028d1f79
commit d93b0bc07d
2 changed files with 11 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ async def cmd_export(app: Client, msg: Message):
selection = msg.command[1].lower()
if selection not in ["applications", "warnings", "sponsorships", "bans"]:
if selection not in ["applications", "warnings", "sponsorships", "bans", "event"]:
await msg.reply_text(
locale("syntax_export", "message", locale=msg.from_user),
quote=should_quote(msg),
@@ -145,6 +145,15 @@ async def cmd_export(app: Client, msg: Message):
output_json.append(entry)
output_csv.append(entry)
elif selection == "event":
header_csv = ["user", "stage", "date"]
for entry in list(col_warnings.find()):
del entry["id"]
entry["date"] = entry["date"].isoformat()
output_json.append(entry)
output_csv.append(entry)
# Saving CSV
async with aiofiles.open(temp_file + ".csv", mode="w", encoding="utf-8") as file:
writer = AsyncDictWriter(file, header_csv, restval="NULL", quoting=QUOTE_ALL)