fix: filtre content_type, doublons seasonaux, et is_admin manquant
- Bug 1: Ajout du champ 'type' dans les dict de AnimeReleasesFetcher (get_seasonal_anime, get_scheduled_anime, get_top_anime, search_anime) et dans _get_fallback_recommendations pour que le filtre content_type fonctionne correctement - Bug 2: Déduplication par mal_id dans get_seasonal_anime() pour éviter les doublons retournés par l'API Jikan - Bug 3: Ajout de is_admin dans get_current_user_from_token(), get_optional_user(), le constructeur User du register, et la réponse /me
This commit is contained in:
@@ -285,6 +285,7 @@ class RecommendationEngine:
|
|||||||
'score': 9.09,
|
'score': 9.09,
|
||||||
'episodes': 64,
|
'episodes': 64,
|
||||||
'status': 'Finished Airing',
|
'status': 'Finished Airing',
|
||||||
|
'type': 'TV',
|
||||||
'genres': ['Action', 'Adventure', 'Fantasy'],
|
'genres': ['Action', 'Adventure', 'Fantasy'],
|
||||||
'synopsis': 'Two brothers lose their mother to an incurable disease. With the power of alchemy, they use taboo knowledge to resurrect her. The process fails, and as a toll for crossing into the realm of God, they lose their bodies.',
|
'synopsis': 'Two brothers lose their mother to an incurable disease. With the power of alchemy, they use taboo knowledge to resurrect her. The process fails, and as a toll for crossing into the realm of God, they lose their bodies.',
|
||||||
'images': {},
|
'images': {},
|
||||||
@@ -298,6 +299,7 @@ class RecommendationEngine:
|
|||||||
'score': 8.51,
|
'score': 8.51,
|
||||||
'episodes': 75,
|
'episodes': 75,
|
||||||
'status': 'Finished Airing',
|
'status': 'Finished Airing',
|
||||||
|
'type': 'TV',
|
||||||
'genres': ['Action', 'Drama', 'Fantasy'],
|
'genres': ['Action', 'Drama', 'Fantasy'],
|
||||||
'synopsis': 'Centuries ago, mankind was slaughtered to near extinction by monstrous humanoid creatures called titans. To protect what remains, humanity built walls and lived peacefully for a hundred years.',
|
'synopsis': 'Centuries ago, mankind was slaughtered to near extinction by monstrous humanoid creatures called titans. To protect what remains, humanity built walls and lived peacefully for a hundred years.',
|
||||||
'images': {},
|
'images': {},
|
||||||
@@ -311,6 +313,7 @@ class RecommendationEngine:
|
|||||||
'score': 8.63,
|
'score': 8.63,
|
||||||
'episodes': 37,
|
'episodes': 37,
|
||||||
'status': 'Finished Airing',
|
'status': 'Finished Airing',
|
||||||
|
'type': 'TV',
|
||||||
'genres': ['Mystery', 'Police', 'Psychological'],
|
'genres': ['Mystery', 'Police', 'Psychological'],
|
||||||
'synopsis': 'A shinigami, as a god of death, can kill any person—provided they see their victim\'s face and write their victim\'s name in a notebook called a Death Note.',
|
'synopsis': 'A shinigami, as a god of death, can kill any person—provided they see their victim\'s face and write their victim\'s name in a notebook called a Death Note.',
|
||||||
'images': {},
|
'images': {},
|
||||||
@@ -324,6 +327,7 @@ class RecommendationEngine:
|
|||||||
'score': 8.48,
|
'score': 8.48,
|
||||||
'episodes': 26,
|
'episodes': 26,
|
||||||
'status': 'Finished Airing',
|
'status': 'Finished Airing',
|
||||||
|
'type': 'TV',
|
||||||
'genres': ['Action', 'Adventure', 'Supernatural'],
|
'genres': ['Action', 'Adventure', 'Supernatural'],
|
||||||
'synopsis': 'It is the Taisho Period in Japan. Tanjiro, a kindhearted boy who sells charcoal for a living, finds his family slaughtered by a demon. To make matters worse, his younger sister Nezuko is turned into a demon.',
|
'synopsis': 'It is the Taisho Period in Japan. Tanjiro, a kindhearted boy who sells charcoal for a living, finds his family slaughtered by a demon. To make matters worse, his younger sister Nezuko is turned into a demon.',
|
||||||
'images': {},
|
'images': {},
|
||||||
@@ -337,6 +341,7 @@ class RecommendationEngine:
|
|||||||
'score': 8.35,
|
'score': 8.35,
|
||||||
'episodes': 24,
|
'episodes': 24,
|
||||||
'status': 'Finished Airing',
|
'status': 'Finished Airing',
|
||||||
|
'type': 'TV',
|
||||||
'genres': ['Action', 'Supernatural'],
|
'genres': ['Action', 'Supernatural'],
|
||||||
'synopsis': 'Yuji Itadori is a boy with tremendous physical strength, though he lives a completely ordinary high school life. One day, to save a friend who has been attacked by curses, he eats the finger of a curse.',
|
'synopsis': 'Yuji Itadori is a boy with tremendous physical strength, though he lives a completely ordinary high school life. One day, to save a friend who has been attacked by curses, he eats the finger of a curse.',
|
||||||
'images': {},
|
'images': {},
|
||||||
|
|||||||
+15
-6
@@ -92,7 +92,12 @@ class AnimeReleasesFetcher:
|
|||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
anime_list = []
|
anime_list = []
|
||||||
for anime in data.get('data', [])[:20]:
|
seen_mal_ids = set()
|
||||||
|
for anime in data.get('data', []):
|
||||||
|
mal_id = anime.get('mal_id')
|
||||||
|
if not mal_id or mal_id in seen_mal_ids:
|
||||||
|
continue
|
||||||
|
seen_mal_ids.add(mal_id)
|
||||||
anime_list.append({
|
anime_list.append({
|
||||||
'title': anime.get('title', ''),
|
'title': anime.get('title', ''),
|
||||||
'title_japanese': anime.get('title_japanese', ''),
|
'title_japanese': anime.get('title_japanese', ''),
|
||||||
@@ -105,9 +110,10 @@ class AnimeReleasesFetcher:
|
|||||||
'cover_image': self._extract_cover_image(anime),
|
'cover_image': self._extract_cover_image(anime),
|
||||||
'images': anime.get('images', {}),
|
'images': anime.get('images', {}),
|
||||||
'url': anime.get('url', ''),
|
'url': anime.get('url', ''),
|
||||||
'mal_id': anime.get('mal_id')
|
'mal_id': mal_id,
|
||||||
|
'type': anime.get('type', '')
|
||||||
})
|
})
|
||||||
return anime_list
|
return anime_list[:20]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error fetching seasonal anime: {e}", exc_info=True)
|
logger.error(f"Error fetching seasonal anime: {e}", exc_info=True)
|
||||||
return []
|
return []
|
||||||
@@ -143,7 +149,8 @@ class AnimeReleasesFetcher:
|
|||||||
'cover_image': self._extract_cover_image(anime),
|
'cover_image': self._extract_cover_image(anime),
|
||||||
'broadcast': anime.get('broadcast', {}),
|
'broadcast': anime.get('broadcast', {}),
|
||||||
'url': anime.get('url', ''),
|
'url': anime.get('url', ''),
|
||||||
'mal_id': anime.get('mal_id')
|
'mal_id': anime.get('mal_id'),
|
||||||
|
'type': anime.get('type', '')
|
||||||
})
|
})
|
||||||
return anime_list
|
return anime_list
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -178,7 +185,8 @@ class AnimeReleasesFetcher:
|
|||||||
'cover_image': self._extract_cover_image(anime),
|
'cover_image': self._extract_cover_image(anime),
|
||||||
'images': anime.get('images', {}),
|
'images': anime.get('images', {}),
|
||||||
'url': anime.get('url', ''),
|
'url': anime.get('url', ''),
|
||||||
'mal_id': anime.get('mal_id')
|
'mal_id': anime.get('mal_id'),
|
||||||
|
'type': anime.get('type', '')
|
||||||
})
|
})
|
||||||
return anime_list
|
return anime_list
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -209,7 +217,8 @@ class AnimeReleasesFetcher:
|
|||||||
'cover_image': self._extract_cover_image(anime),
|
'cover_image': self._extract_cover_image(anime),
|
||||||
'images': anime.get('images', {}),
|
'images': anime.get('images', {}),
|
||||||
'url': anime.get('url', ''),
|
'url': anime.get('url', ''),
|
||||||
'mal_id': anime.get('mal_id')
|
'mal_id': anime.get('mal_id'),
|
||||||
|
'type': anime.get('type', '')
|
||||||
})
|
})
|
||||||
return anime_list
|
return anime_list
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ async def get_current_user_from_token(
|
|||||||
email=user.email,
|
email=user.email,
|
||||||
full_name=user.full_name,
|
full_name=user.full_name,
|
||||||
is_active=user.is_active,
|
is_active=user.is_active,
|
||||||
|
is_admin=user.is_admin,
|
||||||
created_at=user.created_at,
|
created_at=user.created_at,
|
||||||
last_login=user.last_login,
|
last_login=user.last_login,
|
||||||
)
|
)
|
||||||
@@ -79,6 +80,7 @@ async def get_optional_user(
|
|||||||
email=user.email,
|
email=user.email,
|
||||||
full_name=user.full_name,
|
full_name=user.full_name,
|
||||||
is_active=user.is_active,
|
is_active=user.is_active,
|
||||||
|
is_admin=user.is_admin,
|
||||||
created_at=user.created_at,
|
created_at=user.created_at,
|
||||||
last_login=user.last_login,
|
last_login=user.last_login,
|
||||||
)
|
)
|
||||||
@@ -108,6 +110,7 @@ async def register(user_data: UserCreate):
|
|||||||
email=user.email,
|
email=user.email,
|
||||||
full_name=user.full_name,
|
full_name=user.full_name,
|
||||||
is_active=user.is_active,
|
is_active=user.is_active,
|
||||||
|
is_admin=user.is_admin,
|
||||||
created_at=user.created_at,
|
created_at=user.created_at,
|
||||||
last_login=user.last_login,
|
last_login=user.last_login,
|
||||||
)
|
)
|
||||||
@@ -174,6 +177,7 @@ async def get_me(current_user: User = Depends(get_current_user_from_token)):
|
|||||||
"email": current_user.email,
|
"email": current_user.email,
|
||||||
"full_name": current_user.full_name,
|
"full_name": current_user.full_name,
|
||||||
"is_active": current_user.is_active,
|
"is_active": current_user.is_active,
|
||||||
|
"is_admin": current_user.is_admin,
|
||||||
"created_at": current_user.created_at,
|
"created_at": current_user.created_at,
|
||||||
"last_login": current_user.last_login,
|
"last_login": current_user.last_login,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user