This repository was archived by the owner on Jun 8, 2026. It is now read-only.
Fix monitoring thresholds, DateTime consistency, and null safety#2
Open
markdav-is wants to merge 1 commit into
Open
Fix monitoring thresholds, DateTime consistency, and null safety#2markdav-is wants to merge 1 commit into
markdav-is wants to merge 1 commit into
Conversation
- Extract hardcoded monitoring thresholds (70% survival, 30% mortality, 2/3-month intervals) into shared MonitoringThresholds constants - Replace DateTime.Now with DateTime.UtcNow in repository date comparisons to prevent timezone-dependent bugs - Add null-conditional operators to HttpContext.User.Identity.Name access in ApplicationService and MonitoringService to prevent NullReferenceException - Deduplicate intervention-check logic in MonitoringService into a private LogInterventionIfNeeded method - Remove redundant .ToList() call in Garden Index.razor ApplyFilters - Remove DateTime.UtcNow default initializer on GardenPhoto.PhotoDate (all callers set it explicitly from the form) https://claude.ai/code/session_0163zLuh4sc1Uf1xWCo91g9y
There was a problem hiding this comment.
Pull request overview
This PR centralizes monitoring threshold values, improves time-zone correctness by using UTC for date comparisons, and hardens service-layer user identity access to avoid null reference failures.
Changes:
- Introduced
MonitoringThresholdsconstants and replaced scattered magic numbers across server/shared code. - Switched repository date comparisons from
DateTime.NowtoDateTime.UtcNowfor consistent behavior across time zones. - Added null-safe
HttpContextidentity access and deduplicated monitoring intervention logging logic.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
OE.TenTrees/Shared/Models/MonitoringThresholds.cs |
Adds shared constants for survival/mortality thresholds and monitoring intervals. |
OE.TenTrees/Shared/Models/MonitoringModels.cs |
Uses centralized mortality threshold for RequiresIntervention. |
OE.TenTrees/Shared/Models/GardenModels.cs |
Removes PhotoDate default initializer on GardenPhoto. |
OE.TenTrees/Server/Services/MonitoringService.cs |
Adds null-safe observer assignment and extracts repeated intervention logging check. |
OE.TenTrees/Server/Services/ApplicationService.cs |
Adds null-safe applicant/reviewer user ID assignment. |
OE.TenTrees/Server/Repository/MonitoringRepository.cs |
Uses centralized mortality threshold for RequiresAttention. |
OE.TenTrees/Server/Repository/GardenRepository.cs |
Uses centralized thresholds and switches monitoring staleness comparisons to UTC. |
OE.TenTrees/Client/Modules/Garden/Index.razor |
Removes redundant .ToList() during filtering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public int? FileSize { get; set; } | ||
| public GardenPhotoType PhotoType { get; set; } = GardenPhotoType.General; | ||
| public DateTime PhotoDate { get; set; } = DateTime.UtcNow; | ||
| public DateTime PhotoDate { get; set; } |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
MonitoringThresholdsconstants class, replacing scattered literals across 4 filesDateTime.Nowwhich produces incorrect results when server timezone differs from data timezoneNullReferenceExceptioninApplicationServiceandMonitoringServicewhereHttpContext.User.Identity.Namewas accessed without null checksAddMonitoringSessionAsyncandUpdateMonitoringSessionAsyncinto a sharedLogInterventionIfNeededmethod.ToList()in Garden filter and misleadingDateTime.UtcNowdefault initializer onGardenPhoto.PhotoDateFiles changed
Shared/Models/MonitoringThresholds.csServer/Repository/GardenRepository.csDateTime.UtcNowServer/Repository/MonitoringRepository.csServer/Services/MonitoringService.csServer/Services/ApplicationService.csShared/Models/MonitoringModels.csRequiresInterventionShared/Models/GardenModels.csDateTime.UtcNowdefault onPhotoDateClient/Modules/Garden/Index.razor.ToList()Test plan
https://claude.ai/code/session_0163zLuh4sc1Uf1xWCo91g9y
Generated by Claude Code