Sorted Series Printing
Some checks failed
Run Tests on Code / run-tests (push) Successful in 0s
Build and Release Binary File / test (push) Failing after 2s
Build and Release Binary File / build (push) Has been skipped
Build and Release Binary File / upload-release (push) Has been skipped

This commit is contained in:
Neshura 2023-12-18 11:49:52 +01:00
parent 173a93280e
commit 67e02e79fd
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -4,6 +4,7 @@ use chrono::{Duration, Utc};
use tokio::sync::{RwLock, RwLockReadGuard}; use tokio::sync::{RwLock, RwLockReadGuard};
use tokio::time::sleep; use tokio::time::sleep;
use crate::{SharedData}; use crate::{SharedData};
use crate::post_history::{PostHistory, PostHistoryInner};
pub(crate) async fn run<'a>(shared_data: Arc<RwLock<SharedData>>) { pub(crate) async fn run<'a>(shared_data: Arc<RwLock<SharedData>>) {
let mut min_len_series: u32 = 0; let mut min_len_series: u32 = 0;
@ -36,7 +37,9 @@ async fn print_info<'a>(data: RwLockReadGuard<'a, SharedData>, min_len_series: &
data.config.config_reload_seconds data.config.config_reload_seconds
); );
println!("{:#<1$}", "", separator_width); println!("{:#<1$}", "", separator_width);
data.post_history.series.iter().for_each(|(series, post_history)| { let mut sorted_series: Vec<(&String, &PostHistory)> = data.post_history.series.iter().collect();
sorted_series.sort_by(|(a, _), (b, _)| a.cmp(b));
sorted_series.iter().for_each(|(series, post_history)| {
if series.len() > local_min_len_series { if series.len() > local_min_len_series {
local_min_len_series = series.len() + 1; local_min_len_series = series.len() + 1;
@ -45,9 +48,11 @@ async fn print_info<'a>(data: RwLockReadGuard<'a, SharedData>, min_len_series: &
let series_config = data.config.series let series_config = data.config.series
.iter() .iter()
.find(|ser| {&ser.slug == series}) .find(|ser| {&&ser.slug == series})
.expect("Config should not parse without this"); .expect("Config should not parse without this");
post_history.parts.iter().for_each(|(part, part_history)| { let mut sorted_parts: Vec<(&String, &PostHistoryInner)> = post_history.parts.iter().collect();
sorted_parts.sort_by(|(a, _), (b, _)| a.cmp(b));
sorted_parts.iter().for_each(|(part, part_history)| {
if part_history.volume.len() > local_min_len_slug { if part_history.volume.len() > local_min_len_slug {
local_min_len_slug = part_history.chapter.len() + 1; local_min_len_slug = part_history.chapter.len() + 1;