Skip to content

Improvement/gsak import distance followups - #964

Merged
AgreeDK merged 3 commits into
OpenSAK-Org:betafrom
nagisml:improvement/gsak-import-distance-followups
Oct 5, 2026
Merged

AgreeDK merged 3 commits into
OpenSAK-Org:betafrom
nagisml:improvement/gsak-import-distance-followups

Conversation

@nagisml

@nagisml nagisml commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #956: the three non-blocking points from its review.

Changes

  • Progress feedback: GsakImportWorker emits progress(0, 0) before recalculating distances, so the bar switches to busy mode instead of sitting at 100%.
  • One recalculation per target: a new update_distances flag on the worker is set only on the last job for each target. Earlier jobs clear the target's dist_calc_* values instead. If the last job is skipped, fails or is cancelled, distances_up_to_date() reports the distances as stale and the existing check after the import or on a database switch recalculates them.
  • NULL-check index (migration 25, SCHEMA_VERSION 24 → 25): a partial index ix_caches_distance_missing ON caches (id) WHERE distance IS NULL.

Measurements (real database, 183k caches)

Before After
Missing-distance check (startup / DB switch) ~1,100 ms 0.04 ms
Full distance recalculation 10.0 s 10.7 s
Building the index (once, in the migration) – 1.6 s

Note: the schema bump triggers the usual one-time pre-migration backup of each database.

Tests

  • Worker: sends the busy signal; with update_distances=False it clears the stored values instead of recalculating.
  • Dialog: three GSAK databases, two into the same target → flags [False, True, True], no NULL distances left.
  • Cleared dist_calc_* values read back as stale.
  • Migration: the NULL check's query plan uses the new index.

Full suite: 4758 passed, 105 skipped; mypy clean.

maybe a rebase is needed before merge.

… NULL check

- Switch the progress bar to busy mode while distances are recalculated
  after a GSAK import (it sat at 100% with no feedback).
- When several GSAK databases go into the same target, only the last job
  recalculates; earlier jobs clear the stored dist_calc_* values, so the
  existing up-to-date check still catches a skipped/failed last job.
- Migration 25: partial index ix_caches_distance_missing (distance IS NULL),
  so distances_up_to_date()'s NULL check no longer scans the whole table
  (~1 s -> <1 ms at 180k caches).

Follow-up to OpenSAK-Org#956.
…provement/gsak-import-distance-followups
@AgreeDK

AgreeDK commented Oct 5, 2026

Copy link
Copy Markdown
Member

#963 is merged now, so this one has conflicts in db/database.py and gui/dialogs/gsak_import_dialog.py. They look small — the comment in distances_up_to_date() and the worker's run(). Could you rebase onto beta? Worth double-checking after the rebase that _invalidate_distances() and the busy-progress emit still sit correctly in the new session_for()-based run().

…stance-followups

- distances_up_to_date(): use _session_on(db_path), keep index comment
- GsakImportWorker.run(): busy progress and _invalidate_distances() on
  target_path in the session_for()-based run()
- test: stub session_for instead of the removed init_db switch
@nagisml

nagisml commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@AgreeDK merged and aligned to newest Beta. PR in checks

@AgreeDK

AgreeDK commented Oct 5, 2026

Copy link
Copy Markdown
Member

@nagisml
Thanks alot, when I have tester & merged it I will build a new beta with all you work.

@AgreeDK
AgreeDK merged commit 901ebe1 into OpenSAK-Org:beta Oct 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants