caio.co/de/cantine

Make public recipe models more detailed

Now a basic search result item will contain the main image (if it
exists) and a detailed view will expose the instructions.
Id
745e5f0e53f59917d8638be2dcadc061c3ab281f
Author
Caio
Commit time
2020-01-05T13:42:40+01:00

Modified cantine/src/model.rs

@@ -43,6 +43,7
pub name: String,
pub uuid: Uuid,
pub crawl_url: String,
+ pub image: Option<String>,
pub num_ingredients: u8,
pub instructions_length: u32,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -54,12 +55,12
#[derive(Serialize, Deserialize, Debug, Default)]
pub struct RecipeInfo {
pub uuid: Uuid,
-
pub name: String,
pub crawl_url: String,
+ pub images: Vec<String>,

pub ingredients: Vec<String>,
- pub images: Vec<String>,
+ pub instructions: Vec<String>,

pub num_ingredients: u8,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -74,9 +75,10
uuid: src.uuid,
name: src.name,
crawl_url: src.crawl_url,
+ images: src.images,

ingredients: src.ingredients,
- images: src.images,
+ instructions: src.instructions,

num_ingredients: src.features.num_ingredients,
total_time: src.features.total_time,
@@ -91,6 +93,7
name: src.name,
uuid: src.uuid,
crawl_url: src.crawl_url,
+ image: src.images.into_iter().next(),
num_ingredients: src.features.num_ingredients,
instructions_length: src.features.instructions_length,
total_time: src.features.total_time,