MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / resolve_backfill_since

Function resolve_backfill_since

src/sessions_cmd.rs:273–296  ·  view source on GitHub ↗

Resolves the `--since` argument (ISO-8601 or unix seconds) to a unix-second lower bound, defaulting to 90 days before now when unset.

(since: Option<&str>)

Source from the content-addressed store, hash-verified

271/// Resolves the `--since` argument (ISO-8601 or unix seconds) to a unix-second
272/// lower bound, defaulting to 90 days before now when unset.
273fn resolve_backfill_since(since: Option<&str>) -> tracedecay::errors::Result<i64> {
274 let Some(raw) = since.map(str::trim).filter(|value| !value.is_empty()) else {
275 let now = std::time::SystemTime::now()
276 .duration_since(std::time::UNIX_EPOCH)
277 .map(|d| d.as_secs() as i64)
278 .unwrap_or(0);
279 return Ok((now - GIT_BACKFILL_DEFAULT_WINDOW_SECS).max(0));
280 };
281 if let Ok(unix) = raw.parse::<i64>() {
282 if unix >= 0 {
283 return Ok(unix);
284 }
285 return Err(tracedecay::errors::TraceDecayError::Config {
286 message: "--since must be >= 0".to_string(),
287 });
288 }
289 tracedecay::timeutil::parse_rfc3339_timestamp(raw).ok_or_else(|| {
290 tracedecay::errors::TraceDecayError::Config {
291 message: format!(
292 "--since must be a non-negative Unix timestamp or ISO/RFC3339 string (got `{raw}`)"
293 ),
294 }
295 })
296}
297
298async fn ingest_selected_session_sources(
299 db: &tracedecay::global_db::GlobalDb,

Callers 1

run_git_backfillFunction · 0.85

Calls 2

parse_rfc3339_timestampFunction · 0.85
is_emptyMethod · 0.45

Tested by

no test coverage detected