Skip to content

Commit 035efae

Browse files
1 parent e83f46f commit 035efae

5 files changed

Lines changed: 45 additions & 22 deletions

File tree

‎src/cache.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ pub fn load_last() -> Option<SearchResponse> {
5959
/// predates timestamped entries), so replays can report how stale they are.
6060
pub fn last_age_secs() -> Option<u64> {
6161
let modified = std::fs::metadata(last_path()).ok()?.modified().ok()?;
62-
SystemTime::now().duration_since(modified).ok().map(|d| d.as_secs())
62+
SystemTime::now()
63+
.duration_since(modified)
64+
.ok()
65+
.map(|d| d.as_secs())
6366
}
6467

6568
#[derive(Serialize, Deserialize)]

‎src/engine.rs‎

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ pub async fn execute_search(
116116
},
117117
None => set.join_next().await,
118118
};
119-
let Some(join_result) = join_result else { break };
119+
let Some(join_result) = join_result else {
120+
break;
121+
};
120122
match join_result {
121123
Ok((name, Ok(Ok(items)))) => {
122124
for item in &items {
@@ -254,10 +256,7 @@ fn fuse_rrf(buckets: Vec<(String, Vec<SearchResult>)>) -> Vec<SearchResult> {
254256
if f.result.image_url.is_none() {
255257
f.result.image_url = item.image_url;
256258
}
257-
let extra = f
258-
.result
259-
.extra
260-
.get_or_insert_with(|| serde_json::json!({}));
259+
let extra = f.result.extra.get_or_insert_with(|| serde_json::json!({}));
261260
if let Some(obj) = extra.as_object_mut() {
262261
let list = obj
263262
.entry("also_found_by")
@@ -623,11 +622,17 @@ mod tests {
623622
let buckets = vec![
624623
(
625624
"a".to_string(),
626-
vec![result("https://only-a.com", "a"), result("https://both.com", "a")],
625+
vec![
626+
result("https://only-a.com", "a"),
627+
result("https://both.com", "a"),
628+
],
627629
),
628630
(
629631
"b".to_string(),
630-
vec![result("https://only-b.com", "b"), result("https://both.com", "b")],
632+
vec![
633+
result("https://only-b.com", "b"),
634+
result("https://both.com", "b"),
635+
],
631636
),
632637
];
633638
let fused = fuse_rrf(buckets);
@@ -641,11 +646,17 @@ mod tests {
641646
vec![
642647
(
643648
first.to_string(),
644-
vec![result("https://x.com", first), result("https://y.com", first)],
649+
vec![
650+
result("https://x.com", first),
651+
result("https://y.com", first),
652+
],
645653
),
646654
(
647655
second.to_string(),
648-
vec![result("https://y.com", second), result("https://z.com", second)],
656+
vec![
657+
result("https://y.com", second),
658+
result("https://z.com", second),
659+
],
649660
),
650661
]
651662
};
@@ -673,9 +684,15 @@ mod tests {
673684

674685
#[test]
675686
fn synthetic_answers_are_detected_by_scheme() {
676-
assert!(is_synthetic_answer(&result("perplexity://answer", "perplexity")));
687+
assert!(is_synthetic_answer(&result(
688+
"perplexity://answer",
689+
"perplexity"
690+
)));
677691
assert!(is_synthetic_answer(&result("tavily://answer", "tavily")));
678-
assert!(!is_synthetic_answer(&result("https://x.com/search?q=a", "xai")));
692+
assert!(!is_synthetic_answer(&result(
693+
"https://x.com/search?q=a",
694+
"xai"
695+
)));
679696
// A malformed/scheme-less URL is still a result — it must not
680697
// silently vanish into answers[].
681698
assert!(!is_synthetic_answer(&result("example.com/page", "serper")));

‎src/output/table.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ pub fn render(response: &SearchResponse) {
3131
// AI-synthesized answers (Perplexity/Tavily) — separate from web results.
3232
for answer in &response.answers {
3333
if use_color {
34-
println!("{} {}", "answer".on_green().black().bold(), answer.provider.cyan());
34+
println!(
35+
"{} {}",
36+
"answer".on_green().black().bold(),
37+
answer.provider.cyan()
38+
);
3539
println!(" {}", truncate(&answer.text, 600));
3640
println!();
3741
} else {

‎src/registry.rs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,7 @@ mod tests {
269269

270270
#[test]
271271
fn scrape_is_exact_alias_of_extract() {
272-
assert_eq!(
273-
spec(Mode::Scrape).providers,
274-
spec(Mode::Extract).providers
275-
);
272+
assert_eq!(spec(Mode::Scrape).providers, spec(Mode::Extract).providers);
276273
}
277274

278275
#[test]

‎src/usage.rs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ async fn get_json(
6161
let excerpt: String = excerpt.chars().take(160).collect();
6262
return Err(format!("HTTP {status}: {excerpt}"));
6363
}
64-
resp.json::<serde_json::Value>().await.map_err(|e| e.to_string())
64+
resp.json::<serde_json::Value>()
65+
.await
66+
.map_err(|e| e.to_string())
6567
}
6668

6769
/// SerpApi: GET https://serpapi.com/account.json?api_key=...
@@ -125,10 +127,10 @@ async fn xai_usage(ctx: &AppContext, _key: String) -> Result<serde_json::Value,
125127
}
126128
let url = format!("https://management-api.x.ai/v1/billing/teams/{team_id}/prepaid/balance");
127129
let v = get_json(ctx, &url, Some(&mgmt_key), None).await?;
128-
let cents = v
129-
.get("total")
130-
.and_then(|t| t.get("val"))
131-
.and_then(|x| x.as_f64().or_else(|| x.as_str().and_then(|s| s.parse().ok())));
130+
let cents = v.get("total").and_then(|t| t.get("val")).and_then(|x| {
131+
x.as_f64()
132+
.or_else(|| x.as_str().and_then(|s| s.parse().ok()))
133+
});
132134
Ok(serde_json::json!({
133135
"credits_remaining": cents.map(|c| c / 100.0),
134136
"unit": "USD",

0 commit comments

Comments
 (0)