fix: stop the sheet push from splitting a worker's column pair - #1714
Merged
Merged
Conversation
PushToGoogleSheet kept the PlanTimer header row in step with the sites that have an assignment. It looked each header up by its exact text and appended whichever half was missing, on its own, at the end of the row. That is how tenant 1063's columns came apart: a worker's "- tekst" column had gone missing, so a later push appended it after two other workers' pairs, leaving her "- timer" column six columns away. Exact matching also meant a header retyped with other spacing, other capitals or an en dash counted as absent, so the push added a second column for a worker who already had one. PlanAppends now matches existing headers the way the import does -- ignoring case, whitespace and dash style -- and a site missing a half gets a complete new pair, with a problem naming the column left behind so someone can move its data over and delete it. Nothing is moved, renamed or removed, so no column parts company with its data. Also: - only the appended cells are written; rewriting the whole row restated every existing header, silently reverting one a human had corrected - appends start at the first worker column, so they never land in the date columns the import skips and get appended again next time Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The changes align header append behavior with the import’s normalization rules, avoid destructive header rewrites, and are covered by focused unit tests for the new edge cases.
Pull request overview
This PR updates the PlanTimer Google Sheet header “push” logic to prevent a worker/site’s - timer / - tekst column pair from being split or duplicated when headers are hand-edited, and to avoid rewriting existing headers unnecessarily.
Changes:
- Add
PlanTimerSheetColumns.PlanAppends(...)to plan header appends using the same normalization rules as the import (case/whitespace/dash-insensitive matching). - Update
PushToGoogleSheetto write only the appended header cells (not the whole header row) and to start appends at/after the first worker column. - Extend unit tests to cover append planning scenarios including header variants, half-pairs, and empty/short header rows.
File summaries
| File | Description |
|---|---|
| eFormAPI/Plugins/TimePlanning.Pn/TimePlanning.Pn/Infrastructure/Helpers/PlanTimerSheetColumns.cs | Introduces PlanAppends and related helpers to plan safe, normalized header appends without reordering/moving existing columns. |
| eFormAPI/Plugins/TimePlanning.Pn/TimePlanning.Pn/Infrastructure/Helpers/GoogleSheetHelper.cs | Switches header maintenance to PlanAppends, logs problems, and updates only the appended header range. |
| eFormAPI/Plugins/TimePlanning.Pn/TimePlanning.Pn.Test/PlanTimerSheetColumnsTests.cs | Adds unit coverage for the new append-planning behavior and edge cases described in the PR. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Problem
PushToGoogleSheetkeeps the PlanTimer header row in step with the sites that have an assignment. It checked each half of a worker's pair with an exact, case-sensitive string comparison and appended whichever was missing on its own at the end of the row (GoogleSheetHelper.cs:94-107onstable).That is how tenant 1063's columns came apart. Malaika's
- tekstcolumn had gone missing, so a later push appended it at the end — after Valentin's and Phien's pairs, which had been added in between:Exact matching has a second consequence: a header retyped with other spacing, other capitals or an en dash counts as absent, so the push adds a second column for a worker who already has one. Site names ending in a dash (
Julius -) make that easy to trigger.Fix
PlanTimerSheetColumns.PlanAppendsplans the appends:Two further changes:
The import already pairs columns by name (#1712, #1300), so a half appended at the far end still reads correctly. This change is about not making the sheet worse, and about not duplicating columns.
Tests
PlanTimerSheetColumnsTestsgains cases for: nothing to do, a new site, header variants that must not duplicate, tenant 1063's half-pair, an empty sheet, and where the first appended column lands. Pure unit tests, already in both CI shard allowlists.Verified locally:
dotnet buildofTimePlanning.PnandTimePlanning.Pn.Test. Tests run in CI.Related
eform-backendconfiguration-plugincarries its own copy of this helper and gets the same fix, plus the missing header push when a worker is created. Consolidating the three copies (service, this plugin, bcfg) intoMicroting.TimePlanningBaseneeds a base release and is left for later.🤖 Generated with Claude Code