From df8761205518edc0c7abae6a60cf5559c5135b68 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sat, 4 May 2024 15:13:31 -0400 Subject: [PATCH] feat(aurora): added imported_timestamp to metadata on new imports --- aurora/importers/aurora.py | 2 ++ aurora/importers/galacticbot.py | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/aurora/importers/aurora.py b/aurora/importers/aurora.py index 29d153e..d1905e7 100644 --- a/aurora/importers/aurora.py +++ b/aurora/importers/aurora.py @@ -1,6 +1,7 @@ # pylint: disable=duplicate-code import json from datetime import timedelta +from time import time from typing import Dict from discord import ButtonStyle, Interaction, Message, ui @@ -78,6 +79,7 @@ class ImportAuroraView(ui.View): metadata: Dict[str, any] = json.loads(case["metadata"]) if not metadata.get("imported_from"): metadata.update({"imported_from": "Aurora"}) + metadata.update({"imported_timestamp": int(time())}) if case["duration"] != "NULL" and case["duration"] is not None: hours, minutes, seconds = map(int, case["duration"].split(":")) diff --git a/aurora/importers/galacticbot.py b/aurora/importers/galacticbot.py index c6e0b99..3d13b8e 100644 --- a/aurora/importers/galacticbot.py +++ b/aurora/importers/galacticbot.py @@ -1,6 +1,7 @@ # pylint: disable=duplicate-code import json from datetime import timedelta +from time import time from discord import ButtonStyle, Interaction, Message, ui from redbot.core import commands @@ -67,12 +68,12 @@ class ImportGalacticBotView(ui.View): if case["duration"] is not None and float(case["duration"]) != 0: duration = timedelta(seconds=round(float(case["duration"]) / 1000)) else: - duration = "NULL" + duration = None except OverflowError: failed_cases.append(case["case"]) continue - metadata = {"imported_from": "GalacticBot"} + metadata = {"imported_from": "GalacticBot", "imported_timestamp": int(time())} if case["type"] == "SLOWMODE": metadata["seconds"] = case["data"]["seconds"] @@ -113,14 +114,14 @@ class ImportGalacticBotView(ui.View): ] else: resolved = 0 - resolved_by = "NULL" - resolved_reason = "NULL" + resolved_by = None + resolved_reason = None changes = [] if case["reason"] and case["reason"] != "N/A": reason = case["reason"] else: - reason = "NULL" + reason = None await mysql_log( self.ctx.guild.id,