# Path: code/common/database/anonymous_item.py
# class AnonymousItem(CommandItem):
#     def __init__(self, discord_context, command, query, is_valid):
#         self.timestamp = int(discord_context.message.created_at.timestamp() * 1000)
#         self.command = command
#         self.query = query
#         self.is_valid = is_valid
# 
#         self.primary_key_name = CONFIG_OPTIONS.get("boto_primary_key", "QueryId")
#         self.primary_key = self.build_primary_key()
# 
#     ## Methods
# 
#     def to_json(self) -> Dict:
#         return {
#             'timestamp': int(self.timestamp),
#             'command': str(self.command),
#             'query': str(self.query),
#             'is_valid': str(self.is_valid),
#             self.primary_key_name: str(self.primary_key),
#         }
# 
# 
#     def build_primary_key(self) -> str:
#         ## Use a UUID because we can't really guarantee that there won't be collisions with the existing data
#         return str(uuid.uuid4())
# 
# Path: code/common/database/command_item.py
# class CommandItem(metaclass=ABCMeta):
#     @abstractmethod
#     def to_json(self) -> Dict:
#         return
# 
# 
#     @abstractmethod
#     def build_primary_key(self) -> str:
#         return


import base64
import logging
from typing import Dict
from .anonymous_item import AnonymousItem
from .command_item import CommandItem
from common import utilities
        self.expires_on = (self.timestamp / 1000) + CONFIG_OPTIONS.get("database_detailed_table_ttl_seconds", 31536000)

        self.primary_key_name = CONFIG_OPTIONS.get("boto_primary_key", "QueryId")
        self.primary_key = self.build_primary_key()

    ## Methods

    def to_json(self) -> Dict:
        return {
            'user_id': int(self.user_id),
            'user_name': str(self.user_name),
            'timestamp': int(self.timestamp),
            'channel_id': int(self.channel_id),
            'channel_name': str(self.channel_name),
            'server_id': int(self.server_id),
            'server_name': str(self.server_name),
            'query': str(self.query),
            'command': str(self.command),
            'is_valid': bool(self.is_valid),
            'expires_on': int(self.expires_on),
            self.primary_key_name: str(self.primary_key),
        }


    def build_primary_key(self) -> str:
        concatenated = "{}{}".format(self.user_id, self.timestamp)

        return base64.b64encode(bytes(concatenated, "utf-8")).decode("utf-8")



# Path: code/common/database/anonymous_item.py
# class AnonymousItem(CommandItem):
#     def __init__(self, discord_context, command, query, is_valid):
#         self.timestamp = int(discord_context.message.created_at.timestamp() * 1000)
#         self.command = command
#         self.query = query
#         self.is_valid = is_valid
# 
#         self.primary_key_name = CONFIG_OPTIONS.get("boto_primary_key", "QueryId")
#         self.primary_key = self.build_primary_key()
# 
#     ## Methods
# 
#     def to_json(self) -> Dict:
#         return {
#             'timestamp': int(self.timestamp),
#             'command': str(self.command),
#             'query': str(self.query),
#             'is_valid': str(self.is_valid),
#             self.primary_key_name: str(self.primary_key),
#         }
# 
# 
#     def build_primary_key(self) -> str:
#         ## Use a UUID because we can't really guarantee that there won't be collisions with the existing data
#         return str(uuid.uuid4())
# 
# Path: code/common/database/command_item.py
# class CommandItem(metaclass=ABCMeta):
#     @abstractmethod
#     def to_json(self) -> Dict:
#         return
# 
# 
#     @abstractmethod
#     def build_primary_key(self) -> str:
#         return


# Path: code/common/database/detailed_item.py
import base64
import logging
from typing import Dict
from .anonymous_item import AnonymousItem
from .command_item import CommandItem
from common import utilities

        self.expires_on = (self.timestamp / 1000) + CONFIG_OPTIONS.get("database_detailed_table_ttl_seconds", 31536000)

        self.primary_key_name = CONFIG_OPTIONS.get("boto_primary_key", "QueryId")
        self.primary_key = self.build_primary_key()

    ## Methods

    def to_json(self) -> Dict:
        return {
            'user_id': int(self.user_id),
            'user_name': str(self.user_name),
            'timestamp': int(self.timestamp),
            'channel_id': int(self.channel_id),
            'channel_name': str(self.channel_name),
            'server_id': int(self.server_id),
            'server_name': str(self.server_name),
            'query': str(self.query),
            'command': str(self.command),
            'is_valid': bool(self.is_valid),
            'expires_on': int(self.expires_on),
            self.primary_key_name: str(self.primary_key),
        }


    def build_primary_key(self) -> str:
        concatenated = "{}{}".format(self.user_id, self.timestamp)

        return base64.b64encode(bytes(concatenated, "utf-8")).decode("utf-8")



    def to_anonymous_item(self) -> AnonymousItem: