mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-19 06:00:18 +00:00
feat(db): Score
related Database
methods
This commit is contained in:
parent
35e6fde664
commit
daf2a46632
@ -1,7 +1,7 @@
|
||||
import logging
|
||||
from typing import Optional, Union
|
||||
|
||||
from sqlalchemy import Engine, inspect, select
|
||||
from sqlalchemy import Engine, func, inspect, select
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from .models.config import *
|
||||
@ -138,6 +138,28 @@ class Database(metaclass=Singleton):
|
||||
|
||||
# endregion
|
||||
|
||||
# region Score
|
||||
|
||||
def get_scores(self):
|
||||
stmt = select(Score)
|
||||
with self.sessionmaker() as session:
|
||||
results = list(session.scalars(stmt))
|
||||
return results
|
||||
|
||||
def get_score_by_id(self, score_id: int):
|
||||
stmt = select(Score).where(Score.id == score_id)
|
||||
with self.sessionmaker() as session:
|
||||
result = session.scalar(stmt)
|
||||
return result
|
||||
|
||||
def count_scores(self):
|
||||
stmt = select(func.count(Score.id))
|
||||
with self.sessionmaker() as session:
|
||||
result = session.scalar(stmt)
|
||||
return result or 0
|
||||
|
||||
# endregion
|
||||
|
||||
def get_b30(self):
|
||||
stmt = select(CalculatedPotential.b30).select_from(CalculatedPotential)
|
||||
with self.sessionmaker() as session:
|
||||
|
Loading…
x
Reference in New Issue
Block a user