forked from torrust/torrust-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge torrust#502: Decouple database strcut from API response for `Ca…
…tegory` 09e1620 refactor: [torrust#501] decouple database struct from API response for Category (Jose Celano) Pull request description: Decouple database struct from API response for `Category`. Changes in the database schema should not affect the API contract. ACKs for top commit: josecelano: ACK 09e1620 Tree-SHA512: a518f46bf1bdb3171d7ae0f2a59fdbba832e93640fd1cf7ce670713fa063711e61f5b082a0a5c57ce98c451a1aec0981d973d758c9985bcfedf317c853552339
- Loading branch information
Showing
8 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::databases::database::Category as DatabaseCategory; | ||
|
||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)] | ||
pub struct Category { | ||
pub id: i64, | ||
// Deprecated. Use `id`. | ||
pub category_id: i64, | ||
pub name: String, | ||
pub num_torrents: i64, | ||
} | ||
|
||
#[allow(clippy::module_name_repetitions)] | ||
pub type CategoryId = i64; | ||
|
||
impl From<DatabaseCategory> for Category { | ||
fn from(db_category: DatabaseCategory) -> Self { | ||
Category { | ||
id: db_category.category_id, | ||
category_id: db_category.category_id, | ||
name: db_category.name, | ||
num_torrents: db_category.num_torrents, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters