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
Merged
Conversation
…() 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.
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
Four identical
SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()chains lived acrossfold_db_core/event_monitor.rs(2 sites) andfold_db_core/event_statistics.rs(2 sites). Collapsed into a single sharedpub(super) fn now_secs() -> u64helper inevent_statistics.rs, reused fromevent_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.rsno longer needsstd::time::{SystemTime, UNIX_EPOCH}and that import was dropped.Net diff: −18 +12 = −6 lines.
Test plan
cargo fmt --all -- --checkcleancargo clippy --workspace --all-targets -- -D warningscleancargo test --workspace— all tests pass (includingfold_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