Skip to content

Commit

Permalink
fix: Reflect sequence change within channel
Browse files Browse the repository at this point in the history
  • Loading branch information
noahpistilli committed Jul 2, 2024
1 parent e2e766a commit e644e0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
13 changes: 7 additions & 6 deletions migrations/versions/e68ac4fc8fee_readd_sequence_to_miimsginfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 ###
14 changes: 7 additions & 7 deletions url1/mii.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit e644e0c

Please sign in to comment.