feat: add human readable output to the API
This commit is contained in:
parent
f57ecd19aa
commit
183b2c2c88
6 changed files with 221 additions and 20 deletions
|
|
@ -106,25 +106,11 @@ async fn handle_status(
|
|||
|
||||
let embed = match resp {
|
||||
Ok(resp) if resp.status().is_success() => match resp.json::<CacheStatusResponse>().await {
|
||||
Ok(data) => {
|
||||
let mut embed = build_embed(
|
||||
data.status,
|
||||
data.since.unwrap_or(unix_now()),
|
||||
&state.image_base_url,
|
||||
);
|
||||
|
||||
let mut fields = Vec::new();
|
||||
if let Some(ts) = data.since {
|
||||
fields.push(("Since", format_timestamp(ts), true));
|
||||
}
|
||||
if let Some(ts) = data.last_checked {
|
||||
fields.push(("Last Checked", format_timestamp(ts), true));
|
||||
}
|
||||
if !fields.is_empty() {
|
||||
embed = embed.fields(fields);
|
||||
}
|
||||
embed
|
||||
}
|
||||
Ok(data) => build_embed(
|
||||
data.status,
|
||||
data.since.unwrap_or(unix_now()),
|
||||
&state.image_base_url,
|
||||
),
|
||||
Err(e) => {
|
||||
error!(error = %e, "failed to parse status response");
|
||||
CreateEmbed::new()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue