mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-04-09 17:40:17 +00:00
feat(external): add support for smartrte.github.io
This commit is contained in:
parent
d79c73df8c
commit
8c48d76c65
1
src/arcaea_offline/external/smartrte/__init__.py
vendored
Normal file
1
src/arcaea_offline/external/smartrte/__init__.py
vendored
Normal file
@ -0,0 +1 @@
|
||||
from .b30_csv import SmartRteB30CsvConverter
|
64
src/arcaea_offline/external/smartrte/b30_csv.py
vendored
Normal file
64
src/arcaea_offline/external/smartrte/b30_csv.py
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from ...models import Chart, ScoreBest
|
||||
from ...utils.rating import rating_class_to_text
|
||||
|
||||
|
||||
class SmartRteB30CsvConverter:
|
||||
CSV_ROWS = [
|
||||
"songname",
|
||||
"songId",
|
||||
"Difficulty",
|
||||
"score",
|
||||
"Perfect",
|
||||
"criticalPerfect",
|
||||
"Far",
|
||||
"Lost",
|
||||
"Constant",
|
||||
"singlePTT",
|
||||
]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
session: Session,
|
||||
):
|
||||
self.session = session
|
||||
|
||||
def rows(self) -> list:
|
||||
csv_rows = [self.CSV_ROWS.copy()]
|
||||
|
||||
with self.session as session:
|
||||
results = (
|
||||
session.query(
|
||||
Chart.title,
|
||||
ScoreBest.song_id,
|
||||
ScoreBest.rating_class,
|
||||
ScoreBest.score,
|
||||
ScoreBest.pure,
|
||||
ScoreBest.shiny_pure,
|
||||
ScoreBest.far,
|
||||
ScoreBest.lost,
|
||||
Chart.constant,
|
||||
ScoreBest.potential,
|
||||
)
|
||||
.join(
|
||||
Chart,
|
||||
(Chart.song_id == ScoreBest.song_id)
|
||||
& (Chart.rating_class == ScoreBest.rating_class),
|
||||
)
|
||||
.all()
|
||||
)
|
||||
|
||||
for result in results:
|
||||
# replace the comma in song title because the target project
|
||||
# cannot handle quoted string
|
||||
result = list(result)
|
||||
result[0] = result[0].replace(",", "")
|
||||
result[2] = rating_class_to_text(result[2])
|
||||
# divide constant to float
|
||||
result[-2] = result[-2] / 10
|
||||
# round potential
|
||||
result[-1] = round(result[-1], 5)
|
||||
csv_rows.append(result)
|
||||
|
||||
return csv_rows
|
Loading…
x
Reference in New Issue
Block a user