Add sequences to books by author and translator

This commit is contained in:
2023-05-26 22:44:11 +02:00
parent 74deae076e
commit 4f79ad9a1e
2 changed files with 36 additions and 2 deletions

View File

@@ -241,10 +241,26 @@ impl Format for AuthorBook {
false => "".to_string(),
};
let sequences = match !self.sequences.is_empty() {
true => {
let formated_sequences: String = self
.sequences
.clone()[..min(5, self.sequences.len())]
.into_iter()
.map(|sequence| sequence.format())
.collect::<Vec<String>>()
.join("\n");
let post_fix = if self.sequences.len() > 5 { "\nи др." } else { "" };
format!("Серии:\n{formated_sequences}{post_fix}\n\n")
}
false => "".to_string(),
};
let download_command = (StartDownloadData { id: self.id }).to_string();
let download_links = format!("Скачать:\n📥{download_command}");
format!("{book_title}{annotations}{translators}{download_links}")
format!("{book_title}{annotations}{translators}{sequences}{download_links}")
}
}
@@ -277,9 +293,25 @@ impl Format for TranslatorBook {
false => "".to_string(),
};
let sequences = match !self.sequences.is_empty() {
true => {
let formated_sequences: String = self
.sequences
.clone()[..min(5, self.sequences.len())]
.into_iter()
.map(|sequence| sequence.format())
.collect::<Vec<String>>()
.join("\n");
let post_fix = if self.sequences.len() > 5 { "\nи др." } else { "" };
format!("Серии:\n{formated_sequences}{post_fix}\n\n")
}
false => "".to_string(),
};
let download_command = (StartDownloadData { id: self.id }).to_string();
let download_links = format!("Скачать:\n📥{download_command}");
format!("{book_title}{annotations}{authors}{download_links}")
format!("{book_title}{annotations}{authors}{sequences}{download_links}")
}
}

View File

@@ -168,6 +168,7 @@ pub struct AuthorBook {
// uploaded: String,
pub annotation_exists: bool,
pub translators: Vec<BookAuthor>,
pub sequences: Vec<Sequence>,
}
#[derive(Deserialize, Debug, Clone)]
@@ -180,4 +181,5 @@ pub struct TranslatorBook {
// uploaded: String,
pub annotation_exists: bool,
pub authors: Vec<BookAuthor>,
pub sequences: Vec<Sequence>,
}