diff --git a/bazarr/api.py b/bazarr/api.py index aea8198aa..e4d622234 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -1696,6 +1696,7 @@ class EpisodesWanted(Resource): TableShows.seriesType)\ .join(TableShows, on=(TableEpisodes.sonarrSeriesId == TableShows.sonarrSeriesId))\ .where(wanted_condition)\ + .order_by(TableEpisodes.rowid.desc())\ .limit(length)\ .offset(start)\ .dicts() @@ -1749,7 +1750,7 @@ class MoviesWanted(Resource): TableMovies.tags, TableMovies.monitored)\ .where(wanted_condition)\ - .order_by(TableMovies.radarrId.desc())\ + .order_by(TableMovies.rowid.desc())\ .limit(length)\ .offset(start)\ .dicts() diff --git a/bazarr/database.py b/bazarr/database.py index 8662010ce..9924f8d72 100644 --- a/bazarr/database.py +++ b/bazarr/database.py @@ -8,6 +8,7 @@ from peewee import * from playhouse.sqliteq import SqliteQueueDatabase from playhouse.shortcuts import model_to_dict from playhouse.migrate import * +from playhouse.sqlite_ext import RowIDField from helper import path_mappings from config import settings, get_array_from @@ -69,6 +70,7 @@ class TableBlacklistMovie(BaseModel): class TableEpisodes(BaseModel): + rowid = RowIDField() audio_codec = TextField(null=True) audio_language = TextField(null=True) episode = IntegerField() @@ -140,6 +142,7 @@ class TableLanguagesProfiles(BaseModel): class TableMovies(BaseModel): + rowid = RowIDField() alternativeTitles = TextField(null=True) audio_codec = TextField(null=True) audio_language = TextField(null=True) @@ -163,7 +166,7 @@ class TableMovies(BaseModel): subtitles = TextField(null=True) tags = TextField(null=True) title = TextField() - tmdbId = TextField(primary_key=True) + tmdbId = TextField(unique=True) video_codec = TextField(null=True) year = TextField(null=True)