Repository navigation
Conversation
_add_date_columns joined the backcheck date on the survey KEY, which differs
from the backcheck KEY in normal projects, so backcheck dates and the
"Avg Days" statistics were empty. Join on `{survey_key}__BCCL`, falling back
to survey_key when it is also the merge ID.
Closes #300
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fallback join selected survey_key from the backcheck data even when it
was missing there, raising ColumnNotFoundError. Skip the backcheck date in
that case, and correct the comment on when `{survey_key}__BCCL` is absent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add BACKCHECK_SUFFIX and merged_backcheck_name() in models.py and use them for every "__BCCL" in compute.py and report_ui.py. Extract _join_backcheck_columns, which resolves the backcheck KEY (falling back to survey_key when it is the merge ID) and skips missing columns, and use it for both the backchecker staff join and the backcheck date join. _join_staff_information no longer takes a join_key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Backchecker statistics still return empty when the survey KEY is also the merge ID.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Fixes backcheck date joins when survey and backcheck KEYs differ, restoring accurate “Avg Days” statistics.
Changes:
- Joins backcheck metadata using the backcheck KEY.
- Centralizes the
__BCCLsuffix. - Adds regression tests and changelog documentation.
| File | Description |
|---|---|
src/datasure/checks/backchecks/compute.py |
Adds shared backcheck-column join logic. |
src/datasure/checks/backchecks/models.py |
Defines the suffix constant and naming helper. |
src/datasure/checks/backchecks/report_ui.py |
Uses the centralized naming helper. |
tests/checks/backchecks/test_compute.py |
Tests distinct KEYs and missing columns. |
CHANGELOG.md |
Documents the corrected date join. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
1025
to
+1026
| analysis_with_staff = _join_staff_information( | ||
| backcheck_analysis, data_source, staff_col, survey_key, join_key, staff_type | ||
| backcheck_analysis, data_source, staff_col, survey_key, staff_type |
2 tasks
…ge ID
compute_enumerator_backchecker_stats required `{survey_key}__BCCL` in the
analysis before joining, but the merge adds no such column when survey_key
is also survey_id, so backchecker stats were always empty and the
_join_backcheck_columns fallback was unreachable. Drop the pre-join check
and return empty only when the join could not add the staff column.
_get_staff_configuration no longer returns or needs a join key.
Addresses Copilot review on #319.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
6 of 7 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Pull Request Summary 🚀
What does this PR do? 📝
Fills in backcheck dates, and with them the "Avg Days" statistics, when the survey and backcheck datasets have different KEYs. It also fixes backchecker statistics, which were always empty when the survey KEY is also the merge ID. Closes #300.
Why is this change needed? 🤔
Survey and backcheck submissions normally have different KEYs. Joining the backcheck date on the survey KEY matched nothing, so
backcheck_date_colwas empty. "Avg Days" in the enumerator and backchecker statistics then showed 0.How was this implemented? 🛠️
{survey_key}__BCCL, as the backchecker staff join (_join_staff_information) already does.__BCCLcolumn, so the join falls back to survey_key, which then matches both datasets.survey_keycolumn. That path raisedColumnNotFoundErrorbefore this PR; the spec review found it.compute_enumerator_backchecker_statsreturned empty unless the analysis had a{survey_key}__BCCLcolumn, which the merge never adds in that case. That pre-join check is gone; the function now returns empty only if the join could not add the staff column (backcheck data withoutsurvey_key)._get_staff_configurationno longer returns a join key.Tidy-up (from review):
BACKCHECK_SUFFIXandmerged_backcheck_name(col)inmodels.pyreplace every hard-coded"__BCCL"incompute.pyandreport_ui.py._join_backcheck_columnsis the one place that joins backcheck columns by backcheck KEY. It falls back tosurvey_keywhen that is the merge ID and skips missing columns. Both the backchecker staff join and the backcheck date join use it, so they now behave the same._join_staff_informationno longer takes ajoin_key.Left alone: the "Backchecks" stats column counts survey KEYs. #318 redefines that column.
How to test or reproduce ? 🧪
uv run python -m pytest tests/checks/backchecks/test_compute.py just testNew tests in
tests/checks/backchecks/test_compute.py, all using distinct survey and backcheck KEYs:test_add_date_columns_distinct_survey_and_backcheck_keys[None, None]datestest_stats_avg_days_with_distinct_survey_and_backcheck_keys[enumerator]test_stats_avg_days_with_distinct_survey_and_backcheck_keys[backchecker]test_add_date_columns_backcheck_data_without_keyColumnNotFoundErrortest_backchecker_stats_when_survey_key_is_merge_id(survey_key = merge ID)test_backchecker_stats_empty_when_backcheck_data_has_no_survey_keytest_compute_enumerator_backchecker_stats_backcheckerhad expected empty stats in the merge-ID case, which locked in the bug; it now requires stats.Full suite: 3518 passed, 6 skipped.
test_join_backcheck_columns_survey_key_is_merge_idcovers the fallback, andtest_join_staff_information_backchecker_pathnow uses distinct KEYs.Manual: open a backchecks page whose survey and backcheck data have distinct KEYs and a configured backcheck date. "Avg Days" in the Enumerator/Backchecker statistics is now non-zero.
Merge risk: low and easy to undo (revert the commits). It affects only the backcheck date join and backchecker statistics: "Avg Days" changes from 0 to its real value, and backchecker statistics appear where they were empty.
Screenshots (if applicable) 📷
N/A. There is no layout change, only values.
Checklist ✅
Reviewer Emoji Legend
:code::smiley::+1::100:...and I want the author to know it! This is a way to highlight positive parts of a code review.
:star: :star: :star:And I am providing reasons why it needs to be addressed as well as suggested improvements.
:star: :star:And I am providing suggestions where it could be improved either in this PR or later.
:star:...and consider this a suggestion, not a requirement.
:question:This should be a fully formed question with sufficient information and context that requires a response.
:memo::pick:This does not require any changes and is often better left unsaid. This may include stylistic, formatting, or organization suggestions and should likely be prevented/enforced by linting if they really matter
:recycle:Should include enough context to be actionable and not be considered a nitpick.
🤖 Generated with Claude Code