diff --git a/migrations/versions/e68ac4fc8fee_readd_sequence_to_miimsginfo.py b/migrations/versions/e68ac4fc8fee_readd_sequence_to_miimsginfo.py index 94ff5d82..3a900ad7 100644 --- a/migrations/versions/e68ac4fc8fee_readd_sequence_to_miimsginfo.py +++ b/migrations/versions/e68ac4fc8fee_readd_sequence_to_miimsginfo.py @@ -5,21 +5,22 @@ Create Date: 2024-07-02 17:17:27.054317 """ + from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'e68ac4fc8fee' -down_revision = '42bc7a8c4eb9' +revision = "e68ac4fc8fee" +down_revision = "42bc7a8c4eb9" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('mii_msg_info', schema=None) as batch_op: - batch_op.add_column(sa.Column('seq', sa.Integer())) + with op.batch_alter_table("mii_msg_info", schema=None) as batch_op: + batch_op.add_column(sa.Column("seq", sa.Integer())) # ### end Alembic commands ### op.execute( @@ -40,7 +41,7 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('mii_msg_info', schema=None) as batch_op: - batch_op.drop_column('seq') + with op.batch_alter_table("mii_msg_info", schema=None) as batch_op: + batch_op.drop_column("seq") # ### end Alembic commands ### diff --git a/url1/mii.py b/url1/mii.py index b82ddea8..c40c5275 100644 --- a/url1/mii.py +++ b/url1/mii.py @@ -41,8 +41,10 @@ def mii_met(mii_id): concierge_mii, mii_metadata = retrieved_data # Next, ensure we have msginfo data for this Mii. - db_msginfo = MiiMsgInfo.query.filter_by(mii_id=mii_id).order_by( - MiiMsgInfo.type.asc() + db_msginfo = ( + MiiMsgInfo.query.filter_by(mii_id=mii_id) + .order_by(MiiMsgInfo.type.asc()) + .order_by(MiiMsgInfo.seq.asc()) ) if db_msginfo is None: # A Mii doesn't have to be a concierge Mii. @@ -59,11 +61,9 @@ def mii_met(mii_id): separate[info.type] = [] # As seq/msg can repeat within a single msginfo, we add with a RepeatedKey. - # Sequencing is handled by a newline in the messages. - for i, msg in enumerate(info.msg.split("\n")): - separate[info.type].append( - RepeatedElement({"seq": i + 1, "msg": msg, "face": info.face}) - ) + separate[info.type].append( + RepeatedElement({"seq": info.seq, "msg": info.msg, "face": info.face}) + ) # Then, convert all separate types to our actual msginfo type. # In these, the type (our previous dict's key) must be separate.