fix: QA issues — composite index, anchors, fallbacks

- Add composite index ix_translation_records_run_source_hash
  for NOT EXISTS dedup subquery performance + Alembic migration
- Remove duplicate #endregion in orchestrator.py (INV_3)
- Replace hardcoded RU fallback 'Статус' with 'Status'
- Add early return guard to loadMoreRecords()
- Show records summary always when recordsTotal > 0
This commit is contained in:
2026-06-04 13:33:17 +03:00
parent 15d47450a3
commit 339f4e0695
4 changed files with 43 additions and 3 deletions

View File

@@ -0,0 +1,38 @@
"""Add composite index (run_id, source_hash) for NOT EXISTS dedup
Adds ix_translation_records_run_source_hash on translation_records(run_id, source_hash)
to accelerate the correlated NOT EXISTS subquery in orchestrator_query.get_run_records
when deduplicate=true.
Revision ID: c7d8e9f0a1b2
Revises: a1b2c3d4e5f6
Create Date: 2026-06-04 13:30:00.000000
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = "c7d8e9f0a1b2"
down_revision: str | Sequence[str] | None = "a1b2c3d4e5f6"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
"""Create composite index."""
op.create_index(
"ix_translation_records_run_source_hash",
"translation_records",
["run_id", "source_hash"],
postgresql_using="btree",
sqlite=True,
)
def downgrade() -> None:
"""Drop composite index."""
op.drop_index("ix_translation_records_run_source_hash",
table_name="translation_records")

View File

@@ -142,6 +142,8 @@ class TranslationRecord(Base):
__table_args__ = (
Index("ix_translation_records_run_status", "run_id", "status"),
Index("ix_translation_records_source_hash_status", "source_hash", "status"),
Index("ix_translation_records_run_source_hash", "run_id", "source_hash",
comment="Composite index for NOT EXISTS dedup subquery"),
)
# #endregion TranslationRecord

View File

@@ -173,4 +173,3 @@ class TranslationOrchestrator:
# endregion get_run_history
# #endregion TranslationOrchestrator
# #endregion TranslationOrchestrator

View File

@@ -168,6 +168,7 @@ import { SvelteSet } from "svelte/reactivity";
/** Load next page of unique rows and append to records list. */
async function loadMoreRecords() {
if (recordsLoadingMore) return;
recordsLoadingMore = true;
const nextPage = recordsPage + 1;
try {
@@ -319,7 +320,7 @@ import { SvelteSet } from "svelte/reactivity";
</button>
</div>
<div>
<span class="text-text-muted">{_t.translate?.run?.status_label || 'Статус'}</span>
<span class="text-text-muted">{_t.translate?.run?.status_label || 'Status'}</span>
<span class="ml-1 text-xs font-medium text-text">{getRunStatusLabel(status.status)}</span>
</div>
<div>
@@ -586,7 +587,7 @@ import { SvelteSet } from "svelte/reactivity";
</tbody>
</table>
</div>
{#if !allRecordsLoaded && recordsTotal > records.length}
{#if recordsTotal > 0}
<p class="text-xs text-text-subtle mt-1">
{(_t.translate?.run?.showing_records || 'Showing {count} of {total} unique rows.')
.replace('{count}', records.length)