Skip to content

Fixing 955 - #956

Merged
AgreeDK merged 2 commits into
OpenSAK-Org:betafrom
nagisml:improvement/gsak-import-recalc-distances-in-worker
Oct 2, 2026
Merged

AgreeDK merged 2 commits into
OpenSAK-Org:betafrom
nagisml:improvement/gsak-import-recalc-distances-in-worker

Conversation

@nagisml

@nagisml nagisml commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Followup of #947 fixing #955

@AgreeDK

AgreeDK commented Oct 2, 2026

Copy link
Copy Markdown
Member

Thanks, @nagisml
nice, well-scoped fix. Using peek_value()/write_file() so dist_calc_* lands in the target file's own table (rather than the legacy keys while the engine is switched) fits the #659 binding rule well, and the NULL check closes a real gap in distances_up_to_date(). Tests and mypy pass here.

A few non-blocking thoughts, fine as a follow-up:

While the worker recalculates, the progress bar sits at 100% with no feedback. A self.progress.emit(0, 0) just before recalculate_distances() would switch it to busy mode (the dialog already handles total == 0).
When several GSAK databases go into the same target, each job does a full recalc. That's correct, just redundant; recalculating once after the last job per target could be a later optimisation.
The new NULL check means an up-to-date database pays for a full table scan on startup/switch (no index on distance). Probably fine, but worth a quick check on a large DB.

Approving — thanks again!

@AgreeDK
AgreeDK merged commit b91e181 into OpenSAK-Org:beta Oct 2, 2026
7 checks passed
nagisml added a commit to nagisml/OpenSAK that referenced this pull request Oct 2, 2026
…enSAK-Org#956)

After rebasing onto beta, GsakImportWorker still referenced the removed
original_path, and recalculate_distances()/distances_up_to_date() assumed
the global engine had been switched to db_path. With session_for() it no
longer is, so a non-active target's distances would have been computed
from and written to the active database.

- database: _session_on(db_path) picks get_session() for the active DB and
  session_for() otherwise; the distance helpers use it.
- gsak_import_dialog: update distances of target_db_path or the active DB.
- Narrow Optional paths for session_for() and fix the Engine annotation
  in importer (mypy clean).
- test: patch session_for instead of init_db.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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