progscrape_application/story/
render.rs

1use std::collections::HashMap;
2
3use progscrape_scrapers::{ScrapeId, StoryDate, TypedScrape, TypedScrapeMap};
4use serde::{Deserialize, Serialize};
5
6/// Rendered story with all properties hydrated from the underlying scrapes. Extraneous data is removed at this point.
7#[derive(Clone, Default, Debug, Deserialize, Serialize)]
8pub struct StoryRender {
9    /// Natural story order in its container list.
10    pub order: usize,
11    /// An ID useful for pulling the full information for this story.
12    pub id: String,
13    pub url: String,
14    pub domain: String,
15    pub title: String,
16    pub date: StoryDate,
17    pub score: f32,
18    pub tags: Vec<String>,
19    pub sources: TypedScrapeMap<Option<ScrapeId>>,
20}
21
22/// Fully-rendered story, suitable for display on admin screens.
23#[derive(Clone, Default, Deserialize, Serialize)]
24pub struct StoryFullRender {
25    /// Base render flattened into this structure at display time by serde.
26    #[serde(flatten)]
27    pub base: StoryRender,
28
29    pub url_norm: String,
30    pub url_norm_hash: i64,
31
32    /// Fully-detailed scrapes
33    pub scrapes: HashMap<ScrapeId, TypedScrape>,
34}