From a2fe83ae061ccc32d1b8afdd52bf1c94e9604f20 Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Tue, 28 May 2024 22:32:38 -0400 Subject: [PATCH] cxb: add grade to playlog --- .../7dc13e364e53_cxb_add_playlog_grade.py | 28 +++++++++++++++++++ titles/cxb/rev.py | 1 + titles/cxb/schema/score.py | 3 ++ 3 files changed, 32 insertions(+) create mode 100644 core/data/alembic/versions/7dc13e364e53_cxb_add_playlog_grade.py diff --git a/core/data/alembic/versions/7dc13e364e53_cxb_add_playlog_grade.py b/core/data/alembic/versions/7dc13e364e53_cxb_add_playlog_grade.py new file mode 100644 index 0000000..abde273 --- /dev/null +++ b/core/data/alembic/versions/7dc13e364e53_cxb_add_playlog_grade.py @@ -0,0 +1,28 @@ +"""cxb_add_playlog_grade + +Revision ID: 7dc13e364e53 +Revises: 2d024cf145a1 +Create Date: 2024-05-28 22:31:22.264926 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = '7dc13e364e53' +down_revision = '2d024cf145a1' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('cxb_playlog', sa.Column('grade', sa.Integer(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('cxb_playlog', 'grade') + # ### end Alembic commands ### diff --git a/titles/cxb/rev.py b/titles/cxb/rev.py index f811721..7e4f591 100644 --- a/titles/cxb/rev.py +++ b/titles/cxb/rev.py @@ -40,6 +40,7 @@ class CxbRev(CxbBase): score_data["slow2"], score_data["fail"], score_data["combo"], + score_data["grade"], ) return {"data": True} return {"data": True} diff --git a/titles/cxb/schema/score.py b/titles/cxb/schema/score.py index 7be33d8..5acc1ae 100644 --- a/titles/cxb/schema/score.py +++ b/titles/cxb/schema/score.py @@ -39,6 +39,7 @@ playlog = Table( Column("slow2", Integer), Column("fail", Integer), Column("combo", Integer), + Column("grade", Integer), Column("date_scored", TIMESTAMP, server_default=func.now()), mysql_charset="utf8mb4", ) @@ -104,6 +105,7 @@ class CxbScoreData(BaseData): this_slow2: int, fail: int, combo: int, + grade: int, ) -> Optional[int]: """ Add an entry to the user's play log @@ -123,6 +125,7 @@ class CxbScoreData(BaseData): slow2=this_slow2, fail=fail, combo=combo, + grade=grade, ) result = await self.execute(sql)