mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-17 21:30:18 +00:00
fix(db)!: remove r10 calculation, see #1
This commit is contained in:
parent
08b1013820
commit
2fd9478b6a
@ -59,31 +59,31 @@ def calculate_b30(calculated_list: List[Calculated]) -> Decimal:
|
||||
return (sum_ptt_list / len(ptt_list)) if sum_ptt_list else Decimal("0.0")
|
||||
|
||||
|
||||
def get_r10_calculated_list(calculated_list: List[Calculated]) -> List[Calculated]:
|
||||
recent_scores: Dict[str, Calculated] = {}
|
||||
for calculated in calculated_list:
|
||||
key = f"{calculated.song_id}_{calculated.rating_class}"
|
||||
stored = recent_scores.get(key)
|
||||
if stored is None or stored.time < calculated.time:
|
||||
recent_scores[key] = calculated
|
||||
ret_list = list(recent_scores.values())
|
||||
ret_list = sorted(ret_list, key=lambda c: c.time, reverse=True)[:10]
|
||||
return ret_list
|
||||
# def get_r10_calculated_list(calculated_list: List[Calculated]) -> List[Calculated]:
|
||||
# recent_scores: Dict[str, Calculated] = {}
|
||||
# for calculated in calculated_list:
|
||||
# key = f"{calculated.song_id}_{calculated.rating_class}"
|
||||
# stored = recent_scores.get(key)
|
||||
# if stored is None or stored.time < calculated.time:
|
||||
# recent_scores[key] = calculated
|
||||
# ret_list = list(recent_scores.values())
|
||||
# ret_list = sorted(ret_list, key=lambda c: c.time, reverse=True)[:10]
|
||||
# return ret_list
|
||||
|
||||
|
||||
def calculate_r10(calculated_list: List[Calculated]) -> Decimal:
|
||||
ptt_list = [Decimal(c.potential) for c in get_r10_calculated_list(calculated_list)]
|
||||
sum_ptt_list = sum(ptt_list)
|
||||
return (sum_ptt_list / len(ptt_list)) if sum_ptt_list else Decimal("0.0")
|
||||
# def calculate_r10(calculated_list: List[Calculated]) -> Decimal:
|
||||
# ptt_list = [Decimal(c.potential) for c in get_r10_calculated_list(calculated_list)]
|
||||
# sum_ptt_list = sum(ptt_list)
|
||||
# return (sum_ptt_list / len(ptt_list)) if sum_ptt_list else Decimal("0.0")
|
||||
|
||||
|
||||
def calculate_potential(calculated_list: List[Calculated]) -> Decimal:
|
||||
b30_ptt_list = [
|
||||
Decimal(c.potential) for c in get_b30_calculated_list(calculated_list)
|
||||
]
|
||||
r10_ptt_list = [
|
||||
Decimal(c.potential) for c in get_r10_calculated_list(calculated_list)
|
||||
]
|
||||
b30_sum = sum(b30_ptt_list) or Decimal("0.0")
|
||||
r10_sum = sum(r10_ptt_list) or Decimal("0.0")
|
||||
return (b30_sum + r10_sum) / (len(b30_ptt_list) + len(r10_ptt_list))
|
||||
# def calculate_potential(calculated_list: List[Calculated]) -> Decimal:
|
||||
# b30_ptt_list = [
|
||||
# Decimal(c.potential) for c in get_b30_calculated_list(calculated_list)
|
||||
# ]
|
||||
# r10_ptt_list = [
|
||||
# Decimal(c.potential) for c in get_r10_calculated_list(calculated_list)
|
||||
# ]
|
||||
# b30_sum = sum(b30_ptt_list) or Decimal("0.0")
|
||||
# r10_sum = sum(r10_ptt_list) or Decimal("0.0")
|
||||
# return (b30_sum + r10_sum) / (len(b30_ptt_list) + len(r10_ptt_list))
|
||||
|
@ -195,18 +195,6 @@ class Database(metaclass=Singleton):
|
||||
cursor = conn.cursor()
|
||||
return cursor.execute("SELECT b30 FROM calculated_potential").fetchone()[0]
|
||||
|
||||
def get_r10(self) -> float:
|
||||
with self.conn as conn:
|
||||
cursor = conn.cursor()
|
||||
return cursor.execute("SELECT r10 FROM calculated_potential").fetchone()[0]
|
||||
|
||||
def get_potential(self) -> float:
|
||||
with self.conn as conn:
|
||||
cursor = conn.cursor()
|
||||
return cursor.execute(
|
||||
"SELECT potential FROM calculated_potential"
|
||||
).fetchone()[0]
|
||||
|
||||
def insert_score(self, score: DbScoreRow):
|
||||
columns = self.__get_columns_from_dataclass(DbScoreRow)
|
||||
columns_clause = self.__get_columns_clause(columns)
|
||||
|
@ -98,25 +98,6 @@ INIT_SQLS: Dict[int, VersionSqls] = {
|
||||
scores.rating_class
|
||||
""",
|
||||
"""
|
||||
CREATE VIEW IF NOT EXISTS recent_10 AS
|
||||
SELECT
|
||||
c.song_id,
|
||||
c.rating_class,
|
||||
MAX(c.potential) AS potential
|
||||
FROM
|
||||
calculated c
|
||||
WHERE
|
||||
c.time IN (
|
||||
SELECT DISTINCT time
|
||||
FROM calculated
|
||||
ORDER BY time DESC
|
||||
LIMIT 10
|
||||
)
|
||||
GROUP BY
|
||||
c.song_id,
|
||||
c.rating_class
|
||||
""",
|
||||
"""
|
||||
CREATE VIEW IF NOT EXISTS best_30 AS
|
||||
SELECT
|
||||
c.song_id,
|
||||
@ -131,31 +112,6 @@ INIT_SQLS: Dict[int, VersionSqls] = {
|
||||
potential DESC
|
||||
LIMIT 30
|
||||
""",
|
||||
"""
|
||||
CREATE VIEW IF NOT EXISTS calculated_potential AS
|
||||
SELECT
|
||||
r10_avg AS r10,
|
||||
b30_avg AS b30,
|
||||
(r10_sum + b30_sum) / (r10_count + b30_count) AS potential
|
||||
FROM
|
||||
(SELECT SUM(potential) AS r10_sum, AVG(potential) AS r10_avg, COUNT(*) AS r10_count FROM recent_10) r10,
|
||||
(SELECT SUM(potential) AS b30_sum, AVG(potential) AS b30_avg, COUNT(*) AS b30_count FROM best_30) b30
|
||||
""",
|
||||
"""
|
||||
CREATE VIEW IF NOT EXISTS song_id_names AS
|
||||
SELECT song_id, name
|
||||
FROM (
|
||||
SELECT song_id, alias AS name FROM aliases
|
||||
UNION ALL
|
||||
SELECT song_id, song_id AS name FROM charts
|
||||
UNION ALL
|
||||
SELECT song_id, name_en AS name FROM charts
|
||||
UNION ALL
|
||||
SELECT song_id, name_jp AS name FROM charts
|
||||
) AS subquery
|
||||
WHERE name IS NOT NULL AND name <> ''
|
||||
GROUP BY song_id, name
|
||||
""",
|
||||
],
|
||||
"update": [],
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user