Added event data export
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user