mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-19 06:00:18 +00:00
refactor(models)!: Score
& ChartInfo
column changed
This commit is contained in:
parent
01bfd0f350
commit
167f72f9bb
@ -73,7 +73,7 @@ class Database(metaclass=Singleton):
|
|||||||
stmt = select(Property.value).where(Property.key == "version")
|
stmt = select(Property.value).where(Property.key == "version")
|
||||||
result = session.execute(stmt).fetchone()
|
result = session.execute(stmt).fetchone()
|
||||||
if not checkfirst or not result:
|
if not checkfirst or not result:
|
||||||
session.add(Property(key="version", value="3"))
|
session.add(Property(key="version", value="4"))
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
def check_init(self) -> bool:
|
def check_init(self) -> bool:
|
||||||
@ -191,7 +191,7 @@ class Database(metaclass=Singleton):
|
|||||||
stmt = (
|
stmt = (
|
||||||
select(func.count())
|
select(func.count())
|
||||||
.select_from(ChartInfo)
|
.select_from(ChartInfo)
|
||||||
.where((ChartInfo.constant != None) & (ChartInfo.note != None))
|
.where((ChartInfo.constant != None) & (ChartInfo.notes != None))
|
||||||
)
|
)
|
||||||
with self.sessionmaker() as session:
|
with self.sessionmaker() as session:
|
||||||
result = session.scalar(stmt)
|
result = session.scalar(stmt)
|
||||||
|
22
src/arcaea_offline/external/arcaea/st3.py
vendored
22
src/arcaea_offline/external/arcaea/st3.py
vendored
@ -12,8 +12,6 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class St3ScoreParser(ArcaeaParser):
|
class St3ScoreParser(ArcaeaParser):
|
||||||
CLEAR_TYPES_MAP = {0: -1, 1: 1, 2: 1, 3: 1, 4: 1, 5: 1}
|
|
||||||
|
|
||||||
def __init__(self, filepath):
|
def __init__(self, filepath):
|
||||||
super().__init__(filepath)
|
super().__init__(filepath)
|
||||||
|
|
||||||
@ -22,14 +20,22 @@ class St3ScoreParser(ArcaeaParser):
|
|||||||
with sqlite3.connect(self.filepath) as st3_conn:
|
with sqlite3.connect(self.filepath) as st3_conn:
|
||||||
cursor = st3_conn.cursor()
|
cursor = st3_conn.cursor()
|
||||||
db_scores = cursor.execute(
|
db_scores = cursor.execute(
|
||||||
"SELECT songId, songDifficulty, score, perfectCount, nearCount, missCount, date FROM scores"
|
"SELECT songId, songDifficulty, score, perfectCount, nearCount, missCount, date, modifier FROM scores"
|
||||||
).fetchall()
|
).fetchall()
|
||||||
for song_id, rating_class, score, pure, far, lost, date in db_scores:
|
for (
|
||||||
db_clear_type = cursor.execute(
|
song_id,
|
||||||
|
rating_class,
|
||||||
|
score,
|
||||||
|
pure,
|
||||||
|
far,
|
||||||
|
lost,
|
||||||
|
date,
|
||||||
|
modifier,
|
||||||
|
) in db_scores:
|
||||||
|
clear_type = cursor.execute(
|
||||||
"SELECT clearType FROM cleartypes WHERE songId = ? AND songDifficulty = ?",
|
"SELECT clearType FROM cleartypes WHERE songId = ? AND songDifficulty = ?",
|
||||||
(song_id, rating_class),
|
(song_id, rating_class),
|
||||||
).fetchone()[0]
|
).fetchone()[0]
|
||||||
r10_clear_type = self.CLEAR_TYPES_MAP[db_clear_type]
|
|
||||||
|
|
||||||
date_str = str(date)
|
date_str = str(date)
|
||||||
date = None if len(date_str) < 7 else int(date_str.ljust(10, "0"))
|
date = None if len(date_str) < 7 else int(date_str.ljust(10, "0"))
|
||||||
@ -43,7 +49,9 @@ class St3ScoreParser(ArcaeaParser):
|
|||||||
far=far,
|
far=far,
|
||||||
lost=lost,
|
lost=lost,
|
||||||
date=date,
|
date=date,
|
||||||
r10_clear_type=r10_clear_type,
|
modifier=modifier,
|
||||||
|
clear_type=clear_type,
|
||||||
|
comment="Imported from st3",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class ArcsongDbParser:
|
|||||||
song_id=result[0],
|
song_id=result[0],
|
||||||
rating_class=result[1],
|
rating_class=result[1],
|
||||||
constant=result[2],
|
constant=result[2],
|
||||||
note=result[3] or None,
|
notes=result[3] or None,
|
||||||
)
|
)
|
||||||
results.append(chart)
|
results.append(chart)
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class ArcSongJsonBuilder:
|
|||||||
"version": difficulty.version or song.version or "",
|
"version": difficulty.version or song.version or "",
|
||||||
"difficulty": difficulty.rating * 2 + int(difficulty.rating_plus),
|
"difficulty": difficulty.rating * 2 + int(difficulty.rating_plus),
|
||||||
"rating": chart_info.constant or 0 if chart_info else 0,
|
"rating": chart_info.constant or 0 if chart_info else 0,
|
||||||
"note": chart_info.note or 0 if chart_info else 0,
|
"note": chart_info.notes or 0 if chart_info else 0,
|
||||||
"chart_designer": difficulty.chart_designer or "",
|
"chart_designer": difficulty.chart_designer or "",
|
||||||
"jacket_designer": difficulty.jacket_desginer or "",
|
"jacket_designer": difficulty.jacket_desginer or "",
|
||||||
"jacket_override": difficulty.jacket_override,
|
"jacket_override": difficulty.jacket_override,
|
||||||
|
@ -33,8 +33,11 @@ class Score(ScoresBase):
|
|||||||
lost: Mapped[Optional[int]]
|
lost: Mapped[Optional[int]]
|
||||||
date: Mapped[Optional[int]]
|
date: Mapped[Optional[int]]
|
||||||
max_recall: Mapped[Optional[int]]
|
max_recall: Mapped[Optional[int]]
|
||||||
r10_clear_type: Mapped[Optional[int]] = mapped_column(
|
modifier: Mapped[Optional[int]] = mapped_column(
|
||||||
comment="0: LOST, 1: COMPLETE, 2: HARD_LOST"
|
comment="0: NORMAL, 1: EASY, 2: HARD"
|
||||||
|
)
|
||||||
|
clear_type: Mapped[Optional[int]] = mapped_column(
|
||||||
|
comment="0: TRACK LOST, 1: NORMAL CLEAR, 2: FULL RECALL, 3: PURE MEMORY, 4: EASY CLEAR, 5: HARD CLEAR"
|
||||||
)
|
)
|
||||||
comment: Mapped[Optional[str]] = mapped_column(TEXT())
|
comment: Mapped[Optional[str]] = mapped_column(TEXT())
|
||||||
|
|
||||||
@ -61,7 +64,8 @@ class ScoreCalculated(ScoresViewBase):
|
|||||||
lost: Mapped[Optional[int]]
|
lost: Mapped[Optional[int]]
|
||||||
date: Mapped[Optional[int]]
|
date: Mapped[Optional[int]]
|
||||||
max_recall: Mapped[Optional[int]]
|
max_recall: Mapped[Optional[int]]
|
||||||
r10_clear_type: Mapped[Optional[int]]
|
modifier: Mapped[Optional[int]]
|
||||||
|
clear_type: Mapped[Optional[int]]
|
||||||
potential: Mapped[float]
|
potential: Mapped[float]
|
||||||
comment: Mapped[Optional[str]]
|
comment: Mapped[Optional[str]]
|
||||||
|
|
||||||
@ -76,15 +80,16 @@ class ScoreCalculated(ScoresViewBase):
|
|||||||
(
|
(
|
||||||
Score.score
|
Score.score
|
||||||
- func.floor(
|
- func.floor(
|
||||||
(Score.pure * 10000000.0 / ChartInfo.note)
|
(Score.pure * 10000000.0 / ChartInfo.notes)
|
||||||
+ (Score.far * 0.5 * 10000000.0 / ChartInfo.note)
|
+ (Score.far * 0.5 * 10000000.0 / ChartInfo.notes)
|
||||||
)
|
)
|
||||||
).label("shiny_pure"),
|
).label("shiny_pure"),
|
||||||
Score.far,
|
Score.far,
|
||||||
Score.lost,
|
Score.lost,
|
||||||
Score.date,
|
Score.date,
|
||||||
Score.max_recall,
|
Score.max_recall,
|
||||||
Score.r10_clear_type,
|
Score.modifier,
|
||||||
|
Score.clear_type,
|
||||||
case(
|
case(
|
||||||
(Score.score >= 10000000, ChartInfo.constant / 10.0 + 2),
|
(Score.score >= 10000000, ChartInfo.constant / 10.0 + 2),
|
||||||
(
|
(
|
||||||
@ -127,7 +132,8 @@ class ScoreBest(ScoresViewBase):
|
|||||||
lost: Mapped[Optional[int]]
|
lost: Mapped[Optional[int]]
|
||||||
date: Mapped[Optional[int]]
|
date: Mapped[Optional[int]]
|
||||||
max_recall: Mapped[Optional[int]]
|
max_recall: Mapped[Optional[int]]
|
||||||
r10_clear_type: Mapped[Optional[int]]
|
modifier: Mapped[Optional[int]]
|
||||||
|
clear_type: Mapped[Optional[int]]
|
||||||
potential: Mapped[float]
|
potential: Mapped[float]
|
||||||
comment: Mapped[Optional[str]]
|
comment: Mapped[Optional[str]]
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ class ChartInfo(SongsBase):
|
|||||||
constant: Mapped[int] = mapped_column(
|
constant: Mapped[int] = mapped_column(
|
||||||
comment="real_constant * 10. For example, Crimson Throne [FTR] is 10.4, then store 104 here."
|
comment="real_constant * 10. For example, Crimson Throne [FTR] is 10.4, then store 104 here."
|
||||||
)
|
)
|
||||||
note: Mapped[Optional[int]]
|
notes: Mapped[Optional[int]]
|
||||||
|
|
||||||
|
|
||||||
class SongsViewBase(DeclarativeBase, ReprHelper):
|
class SongsViewBase(DeclarativeBase, ReprHelper):
|
||||||
@ -193,7 +193,7 @@ class Chart(SongsViewBase):
|
|||||||
jacket_override: Mapped[bool]
|
jacket_override: Mapped[bool]
|
||||||
jacket_night: Mapped[Optional[str]]
|
jacket_night: Mapped[Optional[str]]
|
||||||
constant: Mapped[int]
|
constant: Mapped[int]
|
||||||
note: Mapped[Optional[int]]
|
notes: Mapped[Optional[int]]
|
||||||
|
|
||||||
__table__ = create_view(
|
__table__ = create_view(
|
||||||
name=__tablename__,
|
name=__tablename__,
|
||||||
@ -225,7 +225,7 @@ class Chart(SongsViewBase):
|
|||||||
Difficulty.jacket_override,
|
Difficulty.jacket_override,
|
||||||
Difficulty.jacket_night,
|
Difficulty.jacket_night,
|
||||||
ChartInfo.constant,
|
ChartInfo.constant,
|
||||||
ChartInfo.note,
|
ChartInfo.notes,
|
||||||
)
|
)
|
||||||
.select_from(Difficulty)
|
.select_from(Difficulty)
|
||||||
.join(
|
.join(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user