diff --git a/app/dbtables.py b/app/dbtables.py index 279c198..c2da638 100644 --- a/app/dbtables.py +++ b/app/dbtables.py @@ -142,7 +142,6 @@ class TracksTable(Model): duration: Mapped[int] = mapped_column(index=True) fade_at: Mapped[int] = mapped_column(index=False) intro: Mapped[Optional[int]] = mapped_column(default=None) - mtime: Mapped[float] = mapped_column(index=True) path: Mapped[str] = mapped_column(String(2048), index=False, unique=True) silence_at: Mapped[int] = mapped_column(index=False) start_gap: Mapped[int] = mapped_column(index=False) diff --git a/app/helpers.py b/app/helpers.py index 0cd263e..a250a23 100644 --- a/app/helpers.py +++ b/app/helpers.py @@ -346,7 +346,7 @@ def remove_substring_case_insensitive(parent_string: str, substring: str) -> str index = lower_parent.find(lower_substring) # Remove the substring - result = result[:index] + result[index + len(substring):] + result = result[:index] + result[index + len(substring) :] # Update the lowercase versions lower_parent = result.lower() diff --git a/app/models.py b/app/models.py index 79aac49..dc8e731 100644 --- a/app/models.py +++ b/app/models.py @@ -631,7 +631,6 @@ class Tracks(dbtables.TracksTable): start_gap: int, fade_at: int, silence_at: int, - mtime: int, bitrate: int, ): self.path = path @@ -642,7 +641,6 @@ class Tracks(dbtables.TracksTable): self.start_gap = start_gap self.fade_at = fade_at self.silence_at = silence_at - self.mtime = mtime try: session.add(self) diff --git a/migrations/versions/164bd5ef3074_remove_mtime_from_tracks.py b/migrations/versions/164bd5ef3074_remove_mtime_from_tracks.py new file mode 100644 index 0000000..4348f8e --- /dev/null +++ b/migrations/versions/164bd5ef3074_remove_mtime_from_tracks.py @@ -0,0 +1,46 @@ +"""Remove mtime from Tracks + +Revision ID: 164bd5ef3074 +Revises: a524796269fa +Create Date: 2024-12-22 14:11:48.045995 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import mysql + +# revision identifiers, used by Alembic. +revision = '164bd5ef3074' +down_revision = 'a524796269fa' +branch_labels = None +depends_on = None + + +def upgrade(engine_name: str) -> None: + globals()["upgrade_%s" % engine_name]() + + +def downgrade(engine_name: str) -> None: + globals()["downgrade_%s" % engine_name]() + + + + + +def upgrade_() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('tracks', schema=None) as batch_op: + batch_op.drop_index('ix_tracks_mtime') + batch_op.drop_column('mtime') + + # ### end Alembic commands ### + + +def downgrade_() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('tracks', schema=None) as batch_op: + batch_op.add_column(sa.Column('mtime', mysql.FLOAT(), nullable=False)) + batch_op.create_index('ix_tracks_mtime', ['mtime'], unique=False) + + # ### end Alembic commands ### + diff --git a/tests/test_ui.py b/tests/test_ui.py index d7cf1bf..e230def 100644 --- a/tests/test_ui.py +++ b/tests/test_ui.py @@ -63,7 +63,6 @@ class MyTestCase(unittest.TestCase): "start_gap": 60, "fade_at": 236263, "silence_at": 260343, - "mtime": 371900000, }, 2: { "path": "testdata/mom.mp3", @@ -74,7 +73,6 @@ class MyTestCase(unittest.TestCase): "start_gap": 70, "fade_at": 115000, "silence_at": 118000, - "mtime": 1642760000, }, }