fix: downloaded episodes no longer appear as missing
Use the database as the authoritative source for missing-episode lists so that episodes marked is_downloaded=True are never shown as missing, even when the in-memory state is stale. Key changes: - EpisodeService.get_by_series() gains only_missing flag - AnimeService uses DB-backed episodeDict and preserves downloaded episodes during sync, skipping them when adding/removing missing episodes - DownloadService broadcasts series_updated after marking an episode downloaded so the frontend reflects the change immediately - Frontend filters out series with zero missing episodes client-side and fixes renderSeries to respect the active filter - Unit tests updated to assert the broadcast is sent
This commit is contained in:
@@ -541,6 +541,7 @@ class EpisodeService:
|
||||
db: AsyncSession,
|
||||
series_id: int,
|
||||
season: Optional[int] = None,
|
||||
only_missing: bool = False,
|
||||
) -> List[Episode]:
|
||||
"""Get episodes for a series.
|
||||
|
||||
@@ -548,6 +549,9 @@ class EpisodeService:
|
||||
db: Database session
|
||||
series_id: Foreign key to AnimeSeries
|
||||
season: Optional season filter
|
||||
only_missing: If True, only return episodes where
|
||||
is_downloaded is False (i.e., missing episodes).
|
||||
Default False returns all episodes.
|
||||
|
||||
Returns:
|
||||
List of Episode instances
|
||||
@@ -557,6 +561,9 @@ class EpisodeService:
|
||||
if season is not None:
|
||||
query = query.where(Episode.season == season)
|
||||
|
||||
if only_missing:
|
||||
query = query.where(Episode.is_downloaded == False)
|
||||
|
||||
query = query.order_by(Episode.season, Episode.episode_number)
|
||||
result = await db.execute(query)
|
||||
return list(result.scalars().all())
|
||||
|
||||
Reference in New Issue
Block a user