Skip to content

Commit

Permalink
feat(search): return more important info
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrielFR committed Jan 8, 2025
1 parent 4a7935e commit 6fbc35a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions queries/search_anime.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ query($search: String, $page: Int = 1, $per_page: Int = 10) {
}
media(search: $search, type: ANIME, sort: POPULARITY_DESC) {
id
idMal
title {
romaji
english
native
}
format
status(version: 2)
description(asHtml: true)
coverImage {
extraLarge
large
medium
color
}
bannerImage
siteUrl
}
}
Expand Down
11 changes: 11 additions & 0 deletions queries/search_manga.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@ query($search: String, $page: Int = 1, $per_page: Int = 10) {
}
media(search: $search, type: MANGA, sort: POPULARITY_DESC) {
id
idMal
title {
romaji
english
native
}
format
status(version: 2)
description(asHtml: true)
coverImage {
extraLarge
large
medium
color
}
bannerImage
siteUrl
}
}
Expand Down
16 changes: 15 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use serde::Deserialize;
use std::time::Duration;

use crate::{
models::{Anime, Character, Image, Manga, MediaType, Person, Title, User},
models::{
Anime, Character, Cover, Format, Image, Manga, MediaType, Person, Status, Title, User,
},
Error, Result,
};

Expand Down Expand Up @@ -381,7 +383,13 @@ impl Client {
for media in medias.iter() {
animes.push(Anime {
id: media["id"].as_i64().unwrap(),
id_mal: media["idMal"].as_i64(),
title: Title::deserialize(&media["title"]).unwrap(),
format: Format::deserialize(&media["format"]).unwrap(),
status: Status::deserialize(&media["status"]).unwrap(),
description: media["description"].as_str().unwrap().to_string(),
cover: Cover::deserialize(&media["coverImage"]).unwrap(),
banner: media["bannerImage"].as_str().map(String::from),
url: media["siteUrl"].as_str().unwrap().to_string(),

client: self.clone(),
Expand Down Expand Up @@ -433,7 +441,13 @@ impl Client {
for media in medias.iter() {
mangas.push(Manga {
id: media["id"].as_i64().unwrap(),
id_mal: media["idMal"].as_i64(),
title: Title::deserialize(&media["title"]).unwrap(),
format: Format::deserialize(&media["format"]).unwrap(),
status: Status::deserialize(&media["status"]).unwrap(),
description: media["description"].as_str().unwrap().to_string(),
cover: Cover::deserialize(&media["coverImage"]).unwrap(),
banner: media["bannerImage"].as_str().map(String::from),
url: media["siteUrl"].as_str().unwrap().to_string(),

client: self.clone(),
Expand Down

0 comments on commit 6fbc35a

Please sign in to comment.