Skip to content

Aditya Dhayapulay - Save timer task allocations atomically - #2472

Open
adit24dhaya wants to merge 5 commits into
developmentfrom
feat/split-timer-session
Open

adit24dhaya wants to merge 5 commits into
developmentfrom
feat/split-timer-session

Conversation

@adit24dhaya

@adit24dhaya adit24dhaya commented Nov 5, 2026 •

Copy link
Copy Markdown

Description

Save one timer session as separate entries for its assigned tasks. A five-hour session can become three hours on one task and two on another, with all entries and hour counters committed together.

Original task request

HGN Phase I Bugs and Needed Functionalities — Split One Timer Session Across Multiple Assigned Tasks

Original assignment: (PRIORITY HIGH) (FEATURE REQUEST) Aditya Dhayapulay: Split One Timer Session Across Multiple Assigned Tasks, estimated 15 hours.

Task-request-part1-004

Task-request-part2-005

Task-request-visual-006

Related PRS (if any):

Frontend: OneCommunityGlobal/HighestGoodNetworkApp#5784. Both task branches are required to test split saves. Merge the backend first; existing single-entry requests continue to work.

Main changes explained:

  • Add authenticated self-service POST /TimeEntry/split and receipt lookup GET /TimeEntry/split/:batchId.
  • Validate assigned active tasks and project membership on the server. Derive project/WBS IDs from the task and sanitize descriptions.
  • Commit entries, task/profile counters and a durable session receipt in one MongoDB transaction. Replays return the original receipt; changed allocations conflict. No partial rows or duplicate retry hours.
  • Issue stable timer session keys shared across tabs and reject delayed stops for a different session.
  • Keep exact minute accounting for split entries through later edits/deletions, preserving the legacy accounting behavior of existing entries.

How to test:

  1. Run both task branches against an isolated local database configured as a replica set, as required by the existing time-entry transactions.
  2. Use an active account assigned two active tasks in an active project. Start and pause a timer after at least two minutes.
  3. Open Add Tangible Time Entry, check Worked on multiple tasks?, divide the displayed total between those tasks and enter a separate description/reference for each.
  4. Confirm separate entries, correct task hours, unchanged overall session total and a stopped timer after confirmation.
  5. Retry a lost response or submit the same session from two tabs. Confirm only one batch is recorded. Reject duplicate tasks, wrong totals, another user's identity, inactive tasks and removed assignments.
  6. Edit or delete a one-minute split entry and verify the remaining hours stay accurate.

Validation: 92 tests passed across the real disposable MongoDB transaction suite, validation tests, timer tests and three existing time-entry suites. Babel compiled all 794 source files. Changed production files have no ESLint errors (repository warnings remain).

Screenshots or videos of changes:

The frontend PR includes the allocation UI. Local Week 6 evidence contains light/dark mobile/desktop pictures, code pictures and a short compressed walkthrough. No media files are committed to this branch.

Note:

The browser checks use synthetic tasks and mocked API/stop acknowledgements; database atomicity/concurrency is tested separately against a disposable local replica set. No shared database writes, emails, merges or manual deployments were performed. The new receipt collection is created before the transaction, including on older replica sets.

Implement the Phase I Split One Timer Session Across Multiple Assigned Tasks request. Save allocations and hour counters with a durable receipt in one transaction so lost responses and concurrent retries cannot duplicate time. Preserve minute precision on later edits and deletions.

Task: HGN Phase I Bugs and Needed Functionalities, Split One Timer Session Across Multiple Assigned Tasks

Validation: 91 passing isolated transaction, timer, validation and time-entry regression tests; Babel build and changed-file lint.
CI resolves the newer memory-server driver, which hits MongoDB NODE-7832 under Jest. Supply its documented runtime adapter only in the isolated integration fixture while keeping the real driver and database. Local legacy-driver coverage remains unchanged.

Validation: all 91 affected backend tests pass locally. CI will verify the newer driver path.
Extract transaction failure handling to keep cognitive complexity below the quality gate limit. Read the memory-server driver version with Jest’s module loader to satisfy the repository lint rule without disabling it.
@adit24dhaya
adit24dhaya marked this pull request as ready for review November 5, 2026 22:31
Reject date-shaped objects before normalization so every saved split retains a valid work date. Keep the receipt error handling aligned with Sonar catch naming.
Keep transaction writes sequential, normalize session cleanup, and group task counter options while preserving exact split-entry accounting. Use explicit Node crypto imports. Addresses the five Sonar findings on #2472.
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

1 participant