mirror of
https://github.com/Syfaro/fuzzysearch.git
synced 2024-11-23 15:22:31 +00:00
Fix loading front page.
This commit is contained in:
parent
41a993d0b1
commit
6baf256f09
10
src/main.rs
10
src/main.rs
@ -48,7 +48,7 @@ enum WeasylResponse<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn load_frontpage(client: &reqwest::Client, api_key: &str) -> anyhow::Result<i32> {
|
async fn load_frontpage(client: &reqwest::Client, api_key: &str) -> anyhow::Result<i32> {
|
||||||
let resp: WeasylResponse<Vec<WeasylFrontpageSubmission>> = client
|
let resp: WeasylResponse<Vec<serde_json::Value>> = client
|
||||||
.get("https://www.weasyl.com/api/submissions/frontpage")
|
.get("https://www.weasyl.com/api/submissions/frontpage")
|
||||||
.header("X-Weasyl-API-Key", api_key)
|
.header("X-Weasyl-API-Key", api_key)
|
||||||
.send()
|
.send()
|
||||||
@ -63,9 +63,13 @@ async fn load_frontpage(client: &reqwest::Client, api_key: &str) -> anyhow::Resu
|
|||||||
} => return Err(anyhow::anyhow!(name)),
|
} => return Err(anyhow::anyhow!(name)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let max = subs.into_iter().max_by_key(|sub| sub.id);
|
let max = subs
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|sub| sub.get("submitid").and_then(|id| id.as_i64()))
|
||||||
|
.max()
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
Ok(max.map(|sub| sub.id).unwrap_or_default())
|
Ok(max as i32)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn load_submission(
|
async fn load_submission(
|
||||||
|
Loading…
Reference in New Issue
Block a user