MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / recency_score

Function recency_score

libatomic/src/daemon/services_agent.rs:183–192  ·  view source on GitHub ↗

Recency component in [0, 1]: 1.0 for "just updated", halving every [`RECENCY_HALF_LIFE_DAYS`]. Unparseable timestamps score 0.

(updated_at: &str, now: chrono::DateTime<chrono::Utc>)

Source from the content-addressed store, hash-verified

181 /// Recency component in [0, 1]: 1.0 for "just updated", halving every
182 /// [`RECENCY_HALF_LIFE_DAYS`]. Unparseable timestamps score 0.
183 fn recency_score(updated_at: &str, now: chrono::DateTime<chrono::Utc>) -> f64 {
184 let Ok(updated) = chrono::DateTime::parse_from_rfc3339(updated_at) else {
185 return 0.0;
186 };
187 let age_days = (now - updated.with_timezone(&chrono::Utc)).num_seconds() as f64 / 86_400.0;
188 if age_days <= 0.0 {
189 return 1.0;
190 }
191 0.5_f64.powf(age_days / RECENCY_HALF_LIFE_DAYS)
192 }
193
194 /// Combine the candidate score parts into the final ranking score.
195 fn final_score(candidate: &CandidateScore, recency: f64) -> f64 {

Callers 1

resolve_and_rankFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected