Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

refactor(fold_db_core): dedupe 4 SystemTime now() blocks via now_secs() helper - #706

Merged
shiba4life merged 1 commit into
mainfrom
refactor/fold-db-core-now-secs-helper
May 13, 2026
Merged

refactor(fold_db_core): dedupe 4 SystemTime now() blocks via now_secs() helper#706
shiba4life merged 1 commit into
mainfrom
refactor/fold-db-core-now-secs-helper

Conversation

@shiba4life

Copy link
Copy Markdown
Collaborator

Summary

Four identical SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() chains lived across fold_db_core/event_monitor.rs (2 sites) and fold_db_core/event_statistics.rs (2 sites). Collapsed into a single shared pub(super) fn now_secs() -> u64 helper in event_statistics.rs, reused from event_monitor.rs.

Same dedupe pattern as #705 for progress.rs. Behavior-preserving: the helper uses .unwrap() (not .unwrap_or_default()), so panic-on-clock-before-epoch semantics are unchanged at all four call sites. Different choice from #705 because these files already used .unwrap() — matching what was there.

event_monitor.rs no longer needs std::time::{SystemTime, UNIX_EPOCH} and that import was dropped.

Net diff: −18 +12 = −6 lines.

Test plan

  • cargo fmt --all -- --check clean
  • cargo clippy --workspace --all-targets -- -D warnings clean
  • cargo test --workspace — all tests pass (including fold_db_core::event_monitor::tests::test_event_monitor_observability)
  • git grep 'SystemTime::now' in the two touched files returns only the new helper definition

🤖 Generated with Claude Code

…() helper

Four identical SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()
chains across event_monitor.rs (2 sites) and event_statistics.rs (2 sites)
collapsed into a single pub(super) now_secs() helper defined in
event_statistics.rs and reused from event_monitor.rs.

Behavior-preserving: helper uses .unwrap() so panic-on-clock-before-epoch
semantics are unchanged at all four call sites. Same dedupe pattern as #705
for progress.rs, but .unwrap() preserved (not .unwrap_or_default()) because
that's what these files already used.

event_monitor.rs no longer needs std::time::{SystemTime, UNIX_EPOCH} —
import dropped.
@shiba4life
shiba4life enabled auto-merge May 13, 2026 00:17
@shiba4life
shiba4life added this pull request to the merge queue May 13, 2026
Merged via the queue into main with commit 46e3c1a May 13, 2026
14 checks passed
@shiba4life
shiba4life deleted the refactor/fold-db-core-now-secs-helper branch May 13, 2026 00:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant