mirror of
https://github.com/flibusta-apps/book_bot.git
synced 2025-12-06 15:35:35 +01:00
Refactor
This commit is contained in:
@@ -3,7 +3,7 @@ use std::cmp::min;
|
|||||||
use crate::bots::approved_bot::modules::download::StartDownloadData;
|
use crate::bots::approved_bot::modules::download::StartDownloadData;
|
||||||
|
|
||||||
use super::types::{
|
use super::types::{
|
||||||
AsBook, Author, AuthorBook, Book, BookAuthor, BookGenre, SearchBook, Sequence, Translator,
|
Author, AuthorBook, Book, BookAuthor, BookGenre, SearchBook, Sequence, Translator,
|
||||||
TranslatorBook,
|
TranslatorBook,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -109,8 +109,6 @@ where
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|item| item.current_size == item.max_size)
|
.filter(|item| item.current_size == item.max_size)
|
||||||
.map(|item| item_size - item.current_size)
|
.map(|item| item_size - item.current_size)
|
||||||
.collect::<Vec<usize>>()
|
|
||||||
.into_iter()
|
|
||||||
.sum();
|
.sum();
|
||||||
|
|
||||||
self.items
|
self.items
|
||||||
@@ -152,10 +150,6 @@ pub struct AuthorAnnotation {
|
|||||||
pub file: Option<String>,
|
pub file: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AsBook<T> {
|
|
||||||
fn as_book(&self) -> T;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Clone)]
|
#[derive(Deserialize, Debug, Clone)]
|
||||||
pub struct Book {
|
pub struct Book {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
@@ -193,13 +187,13 @@ impl From<SearchBook> for Book {
|
|||||||
fn from(value: SearchBook) -> Self {
|
fn from(value: SearchBook) -> Self {
|
||||||
Book {
|
Book {
|
||||||
id: value.id,
|
id: value.id,
|
||||||
title: value.title.clone(),
|
title: value.title,
|
||||||
lang: value.lang.clone(),
|
lang: value.lang,
|
||||||
available_types: value.available_types.clone(),
|
available_types: value.available_types,
|
||||||
annotation_exists: value.annotation_exists,
|
annotation_exists: value.annotation_exists,
|
||||||
authors: value.authors.clone(),
|
authors: value.authors,
|
||||||
translators: value.translators.clone(),
|
translators: value.translators,
|
||||||
sequences: value.sequences.clone(),
|
sequences: value.sequences,
|
||||||
genres: vec![],
|
genres: vec![],
|
||||||
pages: None
|
pages: None
|
||||||
}
|
}
|
||||||
@@ -223,13 +217,13 @@ impl From<AuthorBook> for Book {
|
|||||||
fn from(value: AuthorBook) -> Self {
|
fn from(value: AuthorBook) -> Self {
|
||||||
Book {
|
Book {
|
||||||
id: value.id,
|
id: value.id,
|
||||||
title: value.title.clone(),
|
title: value.title,
|
||||||
lang: value.lang.clone(),
|
lang: value.lang,
|
||||||
available_types: value.available_types.clone(),
|
available_types: value.available_types,
|
||||||
annotation_exists: value.annotation_exists,
|
annotation_exists: value.annotation_exists,
|
||||||
authors: vec![],
|
authors: vec![],
|
||||||
translators: value.translators.clone(),
|
translators: value.translators,
|
||||||
sequences: value.sequences.clone(),
|
sequences: value.sequences,
|
||||||
genres: vec![],
|
genres: vec![],
|
||||||
pages: None
|
pages: None
|
||||||
}
|
}
|
||||||
@@ -253,13 +247,13 @@ impl From<TranslatorBook> for Book {
|
|||||||
fn from(value: TranslatorBook) -> Self {
|
fn from(value: TranslatorBook) -> Self {
|
||||||
Book {
|
Book {
|
||||||
id: value.id,
|
id: value.id,
|
||||||
title: value.title.clone(),
|
title: value.title,
|
||||||
lang: value.lang.clone(),
|
lang: value.lang,
|
||||||
available_types: value.available_types.clone(),
|
available_types: value.available_types,
|
||||||
annotation_exists: value.annotation_exists,
|
annotation_exists: value.annotation_exists,
|
||||||
authors: value.authors.clone(),
|
authors: value.authors,
|
||||||
translators: vec![],
|
translators: vec![],
|
||||||
sequences: value.sequences.clone(),
|
sequences: value.sequences,
|
||||||
genres: vec![],
|
genres: vec![],
|
||||||
pages: None
|
pages: None
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user