Skip to content

Commit

Permalink
🚧 Small tweaks and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Sep 4, 2024
1 parent d91d381 commit 1a32e0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
11 changes: 1 addition & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,7 @@ async fn fallible_main(cli: Cli) -> Result {
.build();
let listings: Listings = serde_json::from_str(&marktplaats.search(&request).await?)?;
for listing in listings {
info!(
id = listing.item_id,
timestamp = %listing.timestamp,
title = listing.title,
n_pictures = listing.pictures.len(),
n_image_urls = listing.image_urls.len(),
price = ?listing.price,
seller_name = listing.seller.name,
"Found advertisement",
);
info!(?listing, "Found advertisement");
if let Some(chat_id) = chat_id {
let html = listing.render().into_string();
let url = listing.https_url();
Expand Down
12 changes: 6 additions & 6 deletions src/marktplaats/listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use chrono::{DateTime, Local};
use rust_decimal::Decimal;
use serde::Deserialize;

use crate::prelude::*;

#[derive(Deserialize)]
pub struct Listings {
pub listings: Vec<Listing>,
Expand All @@ -18,10 +16,11 @@ impl IntoIterator for Listings {
}
}

#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
pub struct Listing {
/// Marktplaats item ID, looks like `m2137081815`.
#[serde(rename = "itemId")]
#[allow(dead_code)]
pub item_id: String,

/// Advertisement title.
Expand All @@ -41,7 +40,7 @@ pub struct Listing {
#[serde(default, rename = "pictures")]
pub pictures: Vec<Picture>,

/// Low-quality image URLs.
/// Low-quality image URLs **without schema**.
#[serde(default, rename = "imageUrls")]
pub image_urls: Vec<String>,

Expand Down Expand Up @@ -72,7 +71,7 @@ impl Listing {
}
}

#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
pub struct Seller {
#[serde(rename = "sellerId")]
pub id: u32,
Expand Down Expand Up @@ -164,7 +163,7 @@ pub struct Picture {
pub medium_url: Option<String>,
}

#[derive(Deserialize)]
#[derive(Debug, Deserialize)]
pub struct Location {
#[serde(rename = "cityName")]
pub city_name: String,
Expand All @@ -183,6 +182,7 @@ mod tests {
use rust_decimal_macros::dec;

use super::*;
use crate::prelude::*;

#[test]
fn euro_from_cents_ok() {
Expand Down
6 changes: 3 additions & 3 deletions src/telegram/listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ impl Render for Listing {
a href=(format!("https://maps.apple.com/maps?q={}", self.location.city_name)) {
(self.location.city_name)
}
"\n"
em { (HumanTime::from(self.timestamp)) }
" "
(HumanTime::from(self.timestamp))
"\n\n"
strong { "Price:" } " " (self.price)
"\n\n"
blockquote expandable { (self.description) }
blockquote expandable { (self.description()) }
}
}
}
Expand Down

0 comments on commit 1a32e0f

Please sign in to comment.