diff --git a/src/jnovel/mod.rs b/src/jnovel/mod.rs index 419f3ac..d4a399c 100644 --- a/src/jnovel/mod.rs +++ b/src/jnovel/mod.rs @@ -221,7 +221,7 @@ pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Res // If no parts just use 0 as Part indicator as no Series with Parts has a Part 0 let mut volume_map: HashMap = HashMap::new(); - let mut chapter_map: HashMap = HashMap::new(); + let mut prepub_map: HashMap = HashMap::new(); for volume in volume_brief_data.volumes.iter() { let publishing_date = DateTime::parse_from_rfc3339(&volume.publishing).unwrap(); @@ -282,32 +282,32 @@ pub(crate) async fn check_feed(series_slug: &str, series_has_parts: bool) -> Res .or_insert(new_post_info); } - if let Some(part_info) = get_latest_part(&volume.slug).await? { - let part_post_info = Chapter { + if let Some(prepub_info) = get_latest_prepub(&volume.slug).await? { + let prepub_post_info = Chapter { part: new_part_info, volume: volume.number, - lemmy_info: part_info + lemmy_info: prepub_info }; - chapter_map + prepub_map .entry(part_id) .and_modify(|val| { - if *val < part_post_info { - *val = part_post_info.clone() + if *val < prepub_post_info { + *val = prepub_post_info.clone() } }) - .or_insert(part_post_info); + .or_insert(prepub_post_info); } } let mut result_vec: Vec = volume_map.values().cloned().collect(); - let mut chapter_vec: Vec = chapter_map.values().cloned().collect(); - result_vec.append(&mut chapter_vec); + let mut prepub_vec: Vec = prepub_map.values().cloned().collect(); + result_vec.append(&mut prepub_vec); Ok(result_vec) } -async fn get_latest_part(volume_slug: &str) -> Result, Box> { +async fn get_latest_prepub(volume_slug: &str) -> Result, Box> { let response = HTTP_CLIENT .get(api_url!() + "/volumes/" + volume_slug + "/parts?format=json") .send() @@ -315,13 +315,13 @@ async fn get_latest_part(volume_slug: &str) -> Result, Box .text() .await?; - let mut volume_parts_data: ChapterWrapper = serde_json::from_str(&response)?; - volume_parts_data.parts.reverse(); // Makes breaking out of the parts loop easier + let mut volume_prepub_parts_data: ChapterWrapper = serde_json::from_str(&response)?; + volume_prepub_parts_data.parts.reverse(); // Makes breaking out of the parts loop easier let mut post_details: Option = None; - for part in volume_parts_data.parts.iter() { - let publishing_date = DateTime::parse_from_rfc3339(&part.launch).unwrap(); + for prepub_part in volume_prepub_parts_data.parts.iter() { + let publishing_date = DateTime::parse_from_rfc3339(&prepub_part.launch).unwrap(); if publishing_date > Utc::now() { break } @@ -329,9 +329,9 @@ async fn get_latest_part(volume_slug: &str) -> Result, Box continue } - let post_url = format!("{}/read/{}", jnc_base_url!(), part.slug); + let post_url = format!("{}/read/{}", jnc_base_url!(), prepub_part.slug); post_details = Some(LemmyPostInfo { - title: part.title.clone(), + title: prepub_part.title.clone(), url: Url::parse(&post_url).unwrap(), });