Skip to content

LEGLINK-964: Fix inconsistent timestamp formats in FacilityReportingPlans CRUD - #1828

Merged
arianamihailescu merged 3 commits into
devfrom
LEGLINK-964-timestamp-consistent
Aug 13, 2026
Merged

LEGLINK-964: Fix inconsistent timestamp formats in FacilityReportingPlans CRUD#1828
arianamihailescu merged 3 commits into
devfrom
LEGLINK-964-timestamp-consistent

Conversation

@arianamihailescu

@arianamihailescu arianamihailescu commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🛠️ Description of Changes

CreateDate/ModifyDate are datetime2 columns with no offset, so a value that round-tripped through EF Core comes back DateTimeKind.Unspecified while a value stamped in memory just before SaveChangesAsync stays DateTimeKind.Utc. System.Text.Json only appends "Z" for Kind.Utc, so Create returned a "Z" suffix while Get/Update (which re-fetch first) did not - same field, two different formats depending on the operation. FacilityReportingPlanMapper.ToModel now pins both fields to Utc, mirroring the fix MockEntryMapper already applies to the same problem in MockDmrpApi.

🧪 Testing Performed

Tested locally

🧑‍🔬 Unit Testing

  • [ x] I have written or updated unit tests to cover my changes
  • Coverage: 100.0%

📓 Documentation Updated

Please update any relevant sections in the project documentation that were impacted by the changes in the PR.

Summary by CodeRabbit

  • Bug Fixes

    • Ensured facility reporting plan timestamps are consistently serialized as UTC with a Z suffix.
    • Preserved timestamp values without changing their recorded date or time.
    • Handled missing modification dates correctly.
  • Tests

    • Added coverage for stored, UTC, null, and time-preservation scenarios.

CreateDate/ModifyDate are datetime2 columns with no offset, so a value
that round-tripped through EF Core comes back DateTimeKind.Unspecified
while a value stamped in memory just before SaveChangesAsync stays
DateTimeKind.Utc. System.Text.Json only appends "Z" for Kind.Utc, so
Create returned a "Z" suffix while Get/Update (which re-fetch first)
did not - same field, two different formats depending on the
operation. FacilityReportingPlanMapper.ToModel now pins both fields to
Utc, mirroring the fix MockEntryMapper already applies to the same
problem in MockDmrpApi.
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a9e18464-01ec-4113-82a2-4cab89393c24

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8bad57e6-9673-4b44-b8ea-e3bbe9a832a8

📥 Commits

Reviewing files that changed from the base of the PR and between ba1e746 and 7566b76.

📒 Files selected for processing (2)
  • DotNet/DMRP/Business/Mapping/FacilityReportingPlanMapper.cs
  • DotNet/ServiceTests/UnitTests/DMRP/FacilityReportingPlanMapperTests.cs

📝 Walkthrough

Walkthrough

The mapper now marks CreateDate and nullable ModifyDate values as UTC before serialization. Unit tests verify UTC normalization, null handling, preservation of existing UTC values, and unchanged timestamp hours.

Changes

Facility Reporting Plan timestamp handling

Layer / File(s) Summary
UTC timestamp mapping and validation
DotNet/DMRP/Business/Mapping/FacilityReportingPlanMapper.cs, DotNet/ServiceTests/UnitTests/DMRP/FacilityReportingPlanMapperTests.cs
ToModel specifies UTC for creation and modification timestamps without converting their values. Tests cover unspecified and existing UTC timestamps, null modification dates, and preserved timestamp hours.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: ⚪ Minimal · up to 7566b

The change standardizes timestamp formatting for FacilityReportingPlans and is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description covers the change, testing, unit tests, and coverage; the documentation section is present but does not state whether updates were required.
Title check ✅ Passed The title clearly identifies the inconsistent timestamp formats and the affected FacilityReportingPlans CRUD operations.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch LEGLINK-964-timestamp-consistent

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@arianamihailescu arianamihailescu changed the title Fix inconsistent timestamp formats in FacilityReportingPlans CRUD LEGLINK-964: Fix inconsistent timestamp formats in FacilityReportingPlans CRUD Aug 13, 2026
ValidateAsync used to query for an existing row with the same
facility/mapping/period before every Create and Update, throwing
DuplicateReportingPlanException up front. That extra round trip is
gone: duplicate periods are now reported only when the database's
unique index rejects the save, via TranslateSaveFailureAsync (which
still recognizes the violation from the provider exception first,
falling back to a query only when the exception doesn't name the
index).
@arianamihailescu
arianamihailescu merged commit 2b61c42 into dev Aug 13, 2026
18 checks passed
@arianamihailescu
arianamihailescu deleted the LEGLINK-964-timestamp-consistent branch August 13, 2026 21:04
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