Skip to content

fix(worker): exclude pre-creation checks in today uptime#29

Merged
VrianCao merged 3 commits intoVrianCao:masterfrom
Lumexia:master
Feb 18, 2026
Merged

fix(worker): exclude pre-creation checks in today uptime#29
VrianCao merged 3 commits intoVrianCao:masterfrom
Lumexia:master

Conversation

@Lumexia
Copy link
Contributor

@Lumexia Lumexia commented Feb 18, 2026

Summary

Fixes inconsistent uptime semantics for newly created monitors in public/status.
The synthetic current-day uptime calculation now clamps each monitor’s range start to max(dayStart, monitor.created_at) so pre-creation time is
not counted as unknown/unavailable.

Changes

  • Updated computeTodayPartialUptimeBatch in apps/worker/src/public/status.ts:
    • Added created_at to monitor input.
    • Computed per-monitor monitorRangeStart = max(rangeStart, created_at).
    • Clamped downtime and unknown interval calculations to per-monitor range.
    • Returned zero/null totals if monitor is created after current range end.
  • Updated call site in computePublicStatusPayload to pass created_at.
  • Added regression test in apps/worker/test/public-status.test.ts:
    • clamps synthetic today uptime to monitor creation time for newly created monitors.

Test Plan

  • pnpm lint passes
  • pnpm typecheck passes
  • pnpm test passes
  • Manually tested:
    • Created a new monitor while existing monitors were already present.
    • Opened public status page and inspected today’s uptime tooltip for the new monitor.
    • Verified today’s uptime window is effectively clamped to monitor creation time:
      • Pre-creation period is not counted as unknown.
      • Uptime no longer drops to an artificially tiny value immediately after creation.
    • Confirmed existing monitor status/uptime display behavior remains unchanged.
    • CodeX 2026-02-18 jyDj65wO47@2x

Related Issues

Closes #28

@VrianCao
Copy link
Owner

感谢啊!!一直想修这个,一直被耽搁了结果被我忘记了!
说的是对的,新的 Monitor 建立后应该从下一计时点开始计入数据,而非直接开始,否则就会有 Unknown
回家后我 Review 一下!

@VrianCao VrianCao merged commit 4ad3349 into VrianCao:master Feb 18, 2026
2 checks passed
@Lumexia
Copy link
Contributor Author

Lumexia commented Feb 18, 2026

Sorry, my code seems to have some design issues; it shouldn't be set to UNKNOWN before the first detection, see #30.

@VrianCao
Copy link
Owner

Sorry, my code seems to have some design issues; it shouldn't be set to UNKNOWN before the first detection, see #30.

I will review it soon.

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.

[Bug] Public status uptime incorrectly counts pre-creation time as unknown for new monitors

2 participants