Create new python file for handling sqlalchemy. Removes circular import.
This commit is contained in:
+16
-2
@@ -5,6 +5,10 @@ Contains classes and enum for tracking data on submissions.
|
||||
from enum import Enum
|
||||
|
||||
from nextcord import Embed
|
||||
from sqlalchemy import select
|
||||
|
||||
# pylint: disable=import-error
|
||||
from utilities.sql_alchemy_connection import Category, CategoryGroup, session
|
||||
|
||||
|
||||
class SubmissionState(Enum):
|
||||
@@ -190,9 +194,19 @@ class Submission:
|
||||
|
||||
embed = Embed(title="Highscores Submission", description=description)
|
||||
embed.add_field(name="User Name", value=self.username, inline=False)
|
||||
embed.add_field(name="GroupId", value=self.group_id, inline=False)
|
||||
stmt = (
|
||||
select(CategoryGroup.GroupName)
|
||||
.where(CategoryGroup.GuildId == self.guild_id)
|
||||
.where(CategoryGroup.GroupId == self.group_id)
|
||||
)
|
||||
embed.add_field(name="Group", value=session.scalar(stmt), inline=False)
|
||||
if self.category_id:
|
||||
embed.add_field(name="CategoryId", value=self.category_id, inline=False)
|
||||
stmt = (
|
||||
select(Category.CategoryName)
|
||||
.where(Category.GroupId == self.group_id)
|
||||
.where(Category.CategoryId == self.category_id)
|
||||
)
|
||||
embed.add_field(name="Category", value=session.scalar(stmt), inline=False)
|
||||
if self.score:
|
||||
embed.add_field(name="Score", value=self.score, inline=False)
|
||||
return embed
|
||||
|
||||
Reference in New Issue
Block a user