From 292830ae0f2fc71d83a1061001446ecb48aa8a49 Mon Sep 17 00:00:00 2001 From: Ian Roddis <31021769+iroddis@users.noreply.github.com> Date: Mon, 17 Aug 2026 15:48:50 -0300 Subject: [PATCH] Removing objective_thread_pitch from scopes_info --- ...drop_objective_thread_pitch_from_scope_.py | 29 +++++++++++++++++++ app/crud/scope_info.py | 2 -- app/models/scope_info.py | 5 ---- app/schemas/scope_info.py | 1 - app/services/scope_import.py | 3 -- app/templates/_scopes_table_card.html | 2 -- .../admin/augmented_part_detail.html | 1 - tests/test_augmented_part_detail.py | 2 -- tests/test_scope_guide.py | 4 --- tests/test_scope_import.py | 3 -- 10 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 alembic/versions/235d823a56ee_drop_objective_thread_pitch_from_scope_.py diff --git a/alembic/versions/235d823a56ee_drop_objective_thread_pitch_from_scope_.py b/alembic/versions/235d823a56ee_drop_objective_thread_pitch_from_scope_.py new file mode 100644 index 0000000..bdb3578 --- /dev/null +++ b/alembic/versions/235d823a56ee_drop_objective_thread_pitch_from_scope_.py @@ -0,0 +1,29 @@ +"""drop_objective_thread_pitch_from_scope_infos + +Revision ID: 235d823a56ee +Revises: 04425ce3d4d5 +Create Date: 2026-08-17 15:18:26.763831 +""" + +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision: str = "235d823a56ee" +down_revision: Union[str, None] = "04425ce3d4d5" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + with op.batch_alter_table("scope_infos", schema=None) as batch_op: + batch_op.drop_column("objective_thread_pitch") + + +def downgrade() -> None: + with op.batch_alter_table("scope_infos", schema=None) as batch_op: + batch_op.add_column( + sa.Column("objective_thread_pitch", sa.String(), nullable=True) + ) diff --git a/app/crud/scope_info.py b/app/crud/scope_info.py index 59b8112..72f22fd 100644 --- a/app/crud/scope_info.py +++ b/app/crud/scope_info.py @@ -37,7 +37,6 @@ async def create( magnification_max: float | None = None, model_suffix: str | None = None, objective_lens_diameter_mm: float | None = None, - objective_thread_pitch: str | None = None, ) -> ScopeInfo: info = ScopeInfo( augmented_part_id=augmented_part_id, @@ -45,7 +44,6 @@ async def create( magnification_max=magnification_max, model_suffix=model_suffix, objective_lens_diameter_mm=objective_lens_diameter_mm, - objective_thread_pitch=objective_thread_pitch, ) db.add(info) await db.commit() diff --git a/app/models/scope_info.py b/app/models/scope_info.py index 7167766..002bd87 100644 --- a/app/models/scope_info.py +++ b/app/models/scope_info.py @@ -32,8 +32,3 @@ class ScopeInfo(Base): objective_lens_diameter_mm: Mapped[float | None] = mapped_column( Float, nullable=True, default=None ) - # Kept as the raw string from the sheet (e.g. "0.75", "1/16") so no precision - # or notation is lost; the parsed thread lives on its own AttachmentPoint. - objective_thread_pitch: Mapped[str | None] = mapped_column( - String, nullable=True, default=None - ) diff --git a/app/schemas/scope_info.py b/app/schemas/scope_info.py index ffa359f..e055f07 100644 --- a/app/schemas/scope_info.py +++ b/app/schemas/scope_info.py @@ -6,7 +6,6 @@ class ScopeInfoBase(BaseModel): magnification_max: float | None = None model_suffix: str | None = None objective_lens_diameter_mm: float | None = None - objective_thread_pitch: str | None = None class ScopeInfoRead(ScopeInfoBase): diff --git a/app/services/scope_import.py b/app/services/scope_import.py index eeb94bf..0116711 100644 --- a/app/services/scope_import.py +++ b/app/services/scope_import.py @@ -15,7 +15,6 @@ sub_part_type → SubPartType (get-or-create under "Scope" product_number → AugmentedPart.sku (also the upsert / fit-lookup key) magnification_min / _max → ScopeInfo objective_lens_diameter_mm → ScopeInfo (descriptive only, no attachment point) -objective_thread_pitch → ScopeInfo ocular_outer_diameter_mm → StaticConnection + AttachmentPoint "Ocular" objective_thread → ISO/UNC thread + AttachmentPoint "Objective" ocular_fit → Fit: scope's Ocular AP ↔ referenced part's first AP @@ -75,7 +74,6 @@ EXPECTED_COLUMNS = [ "url", "ocular_outer_diameter_mm", "ocular_fit", - "objective_thread_pitch", "objective_thread", "objective_fit", ] @@ -321,7 +319,6 @@ async def import_scopes(db: AsyncSession, rows: list[dict]) -> ScopeImportResult magnification_max=_num(row.get("magnification_max")), model_suffix=model_suffix, objective_lens_diameter_mm=_num(row.get("objective_lens_diameter_mm")), - objective_thread_pitch=_text(row.get("objective_thread_pitch")), ) # Rebuild attachment points from scratch so re-imports stay idempotent diff --git a/app/templates/_scopes_table_card.html b/app/templates/_scopes_table_card.html index f49aebe..832cf9a 100644 --- a/app/templates/_scopes_table_card.html +++ b/app/templates/_scopes_table_card.html @@ -51,8 +51,6 @@