mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-16 12:50:18 +00:00
fix: typo caculate
-> calculate
This commit is contained in:
parent
d16c25726a
commit
a4f995a6aa
@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
||||
name = "arcaea-offline"
|
||||
version = "0.1.0"
|
||||
authors = [{ name = "283375", email = "log_283375@163.com" }]
|
||||
description = "Caculate your B30 & R10 locally."
|
||||
description = "Calculate your B30 & R10 locally."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
dependencies = []
|
||||
|
@ -1,5 +0,0 @@
|
||||
from .models import Score, Caculated
|
||||
from typing import List
|
||||
|
||||
def calculate_b30(caculated_list: List[Caculated]):
|
||||
scores = []
|
5
src/arcaea_offline/calculate.py
Normal file
5
src/arcaea_offline/calculate.py
Normal file
@ -0,0 +1,5 @@
|
||||
from .models import Score, Calculated
|
||||
from typing import List
|
||||
|
||||
def calculate_b30(calculated_list: List[Calculated]):
|
||||
scores = []
|
@ -1,6 +1,6 @@
|
||||
import os
|
||||
from .utils.singleton import Singleton
|
||||
from .models import DbChartRow, DbPackageRow, DbScoreRow, DbCaculatedRow, DbAliasRow
|
||||
from .models import DbChartRow, DbPackageRow, DbScoreRow, DbCalculatedRow, DbAliasRow
|
||||
import sqlite3
|
||||
from typing import Union, List, Optional
|
||||
from dataclasses import fields, is_dataclass
|
||||
@ -134,7 +134,7 @@ class Database(metaclass=Singleton):
|
||||
)
|
||||
""",
|
||||
"""
|
||||
CREATE VIEW IF NOT EXISTS caculated AS
|
||||
CREATE VIEW IF NOT EXISTS calculated AS
|
||||
SELECT
|
||||
scores.song_id,
|
||||
scores.rating_class,
|
||||
@ -280,14 +280,14 @@ class Database(metaclass=Singleton):
|
||||
DbScoreRow(*row) for row in conn.execute(final_sql, params).fetchall()
|
||||
]
|
||||
|
||||
def get_caculated(
|
||||
def get_calculated(
|
||||
self,
|
||||
*,
|
||||
song_id: Optional[List[str]] = None,
|
||||
rating_class: Optional[List[int]] = None,
|
||||
):
|
||||
with self.conn as conn:
|
||||
columns = ",".join([f"[{field.name}]" for field in fields(DbCaculatedRow)])
|
||||
columns = ",".join([f"[{field.name}]" for field in fields(DbCalculatedRow)])
|
||||
where_clauses = []
|
||||
params = []
|
||||
if song_id:
|
||||
@ -298,12 +298,12 @@ class Database(metaclass=Singleton):
|
||||
f"rating_class IN ({','.join('?'*len(rating_class))})"
|
||||
)
|
||||
params.extend(rating_class)
|
||||
final_sql = f"SELECT {columns} FROM caculated"
|
||||
final_sql = f"SELECT {columns} FROM calculated"
|
||||
if where_clauses:
|
||||
final_sql += " WHERE "
|
||||
final_sql += " AND ".join(where_clauses)
|
||||
return [
|
||||
DbCaculatedRow(*row)
|
||||
DbCalculatedRow(*row)
|
||||
for row in conn.execute(final_sql, params).fetchall()
|
||||
]
|
||||
|
||||
@ -317,7 +317,7 @@ class Database(metaclass=Singleton):
|
||||
rating_class,
|
||||
MAX(potential) AS max_potential
|
||||
FROM
|
||||
caculated
|
||||
calculated
|
||||
GROUP BY
|
||||
song_id,
|
||||
rating_class
|
||||
@ -329,7 +329,7 @@ class Database(metaclass=Singleton):
|
||||
SELECT
|
||||
c.*
|
||||
FROM
|
||||
caculated c
|
||||
calculated c
|
||||
JOIN max_potential m ON c.song_id = m.song_id AND c.rating_class = m.rating_class AND c.potential = m.max_potential
|
||||
ORDER BY
|
||||
potential DESC
|
||||
|
@ -124,7 +124,7 @@ class Score:
|
||||
|
||||
|
||||
@dataclass
|
||||
class DbCaculatedRow:
|
||||
class DbCalculatedRow:
|
||||
song_id: str
|
||||
rating_class: int
|
||||
score: int
|
||||
@ -139,7 +139,7 @@ class DbCaculatedRow:
|
||||
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
class Caculated:
|
||||
class Calculated:
|
||||
song_id: str
|
||||
rating_class: int
|
||||
score: int
|
||||
@ -153,5 +153,5 @@ class Caculated:
|
||||
potential: float
|
||||
|
||||
@classmethod
|
||||
def from_db_row(cls, row: DbCaculatedRow):
|
||||
def from_db_row(cls, row: DbCalculatedRow):
|
||||
return cls(**asdict(row))
|
||||
|
Loading…
x
Reference in New Issue
Block a user