Skip to content

feat(health): add photo gallery directory health check#220

Open
rlorenzo wants to merge 1 commit into
mainfrom
feature/photo-folder-health-check
Open

feat(health): add photo gallery directory health check#220
rlorenzo wants to merge 1 commit into
mainfrom
feature/photo-folder-health-check

Conversation

@rlorenzo

Copy link
Copy Markdown
Contributor

What

Adds a photo-gallery health check that complements the existing disk-space-photos check. Where disk-space-photos only reports free space on the hosting drive, this verifies the ID-card photo share (PhotoGallery:IDCardPhotoPath) is actually reachable and populated, catching a mounted-but-empty or wrong share that a free-space check would happily pass.

Severity model

Status reflects user impact:

Condition Status
Reachable, > 1 photo Healthy
Reachable, <= 1 photo (empty or placeholder-only) Unhealthy (photo data is gone)
Missing / unreachable / unreadable (TEST/PROD) Degraded (app falls back to the default image)
Missing, local dev Healthy ("skipped")

The split is deliberate: an unreachable share degrades gracefully (users see nopic.jpg), so it's yellow; a reachable-but-empty share means photo data loss, so it's the red alarm.

Notes

  • Counts top-level *.jpg with an exact-extension filter to dodge the Windows 3-char wildcard quirk (*.jpg also matching .jpginfo).
  • Wrapped in the existing WithAdaptivePolling so the SMB directory scan runs ~hourly while healthy and every 5 min once failing, rather than on every 5-min dashboard poll.
  • Skipped in Development (the S:\ share isn't mounted on dev machines), mirroring the disk-space-photos pattern.

Tests

PhotoGalleryHealthCheckTests covers every branch: healthy (2 photos), unhealthy (0 and 1 photo), degraded (unreachable dir), dev-skip, exact-.jpg counting, and unconfigured path. Full backend suite green; pre-commit lint/test/verify passed.

@codecov-commenter

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov-commenter

codecov-commenter commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.00000% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.20%. Comparing base (63047b9) to head (c7ff3a0).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...eb/Classes/HealthChecks/PhotoGalleryHealthCheck.cs 81.81% 8 Missing ⚠️
web/Classes/HealthChecks/HealthCheckExtensions.cs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #220      +/-   ##
==========================================
+ Coverage   43.15%   43.20%   +0.04%     
==========================================
  Files         892      894       +2     
  Lines       51697    51860     +163     
  Branches     4824     4845      +21     
==========================================
+ Hits        22310    22406      +96     
- Misses      28843    28908      +65     
- Partials      544      546       +2     
Flag Coverage Δ
backend 43.29% <72.00%> (+0.05%) ⬆️
frontend 41.32% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Comment thread web/Classes/HealthChecks/PhotoGalleryHealthCheck.cs Fixed
@rlorenzo

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds PhotoGalleryHealthCheck to validate configured ID-card photo directories, registering it as a ready-check with photo-count enforcement and environment-aware missing-directory handling. Includes test coverage for all health statuses and edge cases.

Changes

Photo Gallery Health Check

Layer / File(s) Summary
PhotoGalleryHealthCheck core implementation
web/Classes/HealthChecks/PhotoGalleryHealthCheck.cs
Class validates photo path is configured, checks directory reachability, enumerates and counts exact .jpg files only, and returns Healthy (≥2 photos), Unhealthy (<2 photos or unconfigured path), or Degraded (missing directory when flag is false, or IO errors) with diagnostic data.
Health check system registration
web/Classes/HealthChecks/HealthCheckExtensions.cs
AddViperHealthChecks registers the photo-gallery check tagged "ready" with adaptive polling, applying healthyWhenMissing: true in Development and false in other environments.
Test suite with fixture and scenarios
test/HealthChecks/PhotoGalleryHealthCheckTests.cs
Disposable test class creates temporary photo directory per test, validates healthy status with ≥2 .jpg files, unhealthy when path unconfigured or photo count too low, degraded when directory unreachable, and healthy-when-missing flag override behavior; tests assert status, description substring matches, and diagnostic data.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(health): add photo gallery directory health check' directly and accurately summarizes the main change—adding a new health check for photo gallery validation.
Description check ✅ Passed The description thoroughly explains what the health check does, its severity model, implementation details, and test coverage—all clearly related to the changeset.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/photo-folder-health-check

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
web/Classes/HealthChecks/PhotoGalleryHealthCheck.cs (1)

27-35: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Add <summary> tag to constructor documentation.

Constructor documentation has <param> tags but is missing the <summary> tag.

📝 Proposed fix
+        /// <summary>
+        /// Creates a new photo gallery health check.
+        /// </summary>
         /// <param name="photoPath">
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/Classes/HealthChecks/PhotoGalleryHealthCheck.cs` around lines 27 - 35,
Add a <summary> XML doc for the PhotoGalleryHealthCheck constructor summarizing
what the constructor does (e.g., initializes a new PhotoGalleryHealthCheck with
the photoPath and healthyWhenMissing behavior), placed above the existing
<param> tags in the constructor's documentation for the
PhotoGalleryHealthCheck(string? photoPath, bool healthyWhenMissing = false)
method; keep the description concise and mention that healthyWhenMissing causes
a missing directory to be treated as Healthy/"skipped".
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@web/Classes/HealthChecks/PhotoGalleryHealthCheck.cs`:
- Around line 27-35: Add a <summary> XML doc for the PhotoGalleryHealthCheck
constructor summarizing what the constructor does (e.g., initializes a new
PhotoGalleryHealthCheck with the photoPath and healthyWhenMissing behavior),
placed above the existing <param> tags in the constructor's documentation for
the PhotoGalleryHealthCheck(string? photoPath, bool healthyWhenMissing = false)
method; keep the description concise and mention that healthyWhenMissing causes
a missing directory to be treated as Healthy/"skipped".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 56ac7eb5-1bc1-4beb-8415-8e03c8e5fe76

📥 Commits

Reviewing files that changed from the base of the PR and between ca2b76c and 868cfd6.

📒 Files selected for processing (3)
  • test/HealthChecks/PhotoGalleryHealthCheckTests.cs
  • web/Classes/HealthChecks/HealthCheckExtensions.cs
  • web/Classes/HealthChecks/PhotoGalleryHealthCheck.cs

@rlorenzo rlorenzo force-pushed the feature/photo-folder-health-check branch from 868cfd6 to 12dd8e0 Compare June 11, 2026 07:48
@rlorenzo rlorenzo requested a review from Copilot June 11, 2026 07:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new readiness health check to validate that the configured ID-card photo share is not just on a drive with free space, but is actually reachable and contains photo content (detecting mounted-but-empty/wrong shares). Includes unit tests to cover the intended severity model and edge cases.

Changes:

  • Introduced PhotoGalleryHealthCheck to validate reachability + minimum photo count with Degraded/Unhealthy split.
  • Registered the new photo-gallery check in the health check wiring (with adaptive polling).
  • Added PhotoGalleryHealthCheckTests to cover all major result branches and the exact-.jpg counting behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
web/Classes/HealthChecks/PhotoGalleryHealthCheck.cs New health check that probes the photo directory and reports status + telemetry data.
web/Classes/HealthChecks/HealthCheckExtensions.cs Registers the new photo-gallery readiness check alongside existing disk-space checks.
test/HealthChecks/PhotoGalleryHealthCheckTests.cs Unit tests covering healthy/unhealthy/degraded/dev-skip/unconfigured-path behaviors.

Comment thread web/Classes/HealthChecks/PhotoGalleryHealthCheck.cs Outdated
Comment thread web/Classes/HealthChecks/HealthCheckExtensions.cs Outdated
Adds a photo-gallery check that complements disk-space-photos: it
confirms the ID-card photo share is reachable and holds more than one
photo, catching a mounted-but-empty or wrong share that a free-space
check would pass.

- Severity tracks user impact: an unreachable share is Degraded (the app
  still works, falling back to the default image) while a reachable but
  near-empty share is Unhealthy (the photo data itself is gone)
- Wrapped in adaptive polling so the SMB directory scan runs hourly while
  healthy and every 5 min once failing, instead of on every 5-min poll
- Skipped (Healthy) in Development, where the share is not mounted
@rlorenzo rlorenzo force-pushed the feature/photo-folder-health-check branch from 12dd8e0 to c7ff3a0 Compare June 11, 2026 08:02
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.

4 participants