Skip to content

Commit

Permalink
[build] Better update and fix for db update
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Sep 20, 2023
1 parent 8ba4992 commit 080ed49
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,15 +1102,8 @@ def db_reset__series_searched_state(self):
self.series_file_model.update(Searched=False).where(
self.series_file_model.EntryId.in_(series_ids)
).execute()
Ids = [
id
for id in self.model_arr_series_file.select(
self.model_arr_series_file.Id
).execute()
]
self.series_file_model.delete().where(
self.series_file_model.EntryId.not_in(Ids)
).execute()
Ids = [id for id in self.model_arr_file.select(self.model_arr_file.Id).execute()]
self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute()

def db_reset__episode_searched_state(self):
self.model_file: EpisodeFilesModel
Expand All @@ -1120,8 +1113,10 @@ def db_reset__episode_searched_state(self):
self.model_file.update(Searched=False).where(
self.model_file.Searched == True
).execute()
Ids = [id for id in self.model_arr_file.select(self.model_arr_file.Id).execute()]
self.file_model.delete().where(self.file_model.EntryId.not_in(Ids)).execute()
Ids = [id for id in self.model_arr_series_file.select().execute()]
self.series_file_model.delete().where(
self.series_file_model.EntryId.not_in(Ids)
).execute()

def db_reset__movie_searched_state(self):
self.model_file: MoviesFilesModel
Expand All @@ -1132,7 +1127,7 @@ def db_reset__movie_searched_state(self):
self.model_file.Searched == True
).execute()
Ids = [id for id in self.model_arr_file.select(self.model_arr_file.Id).execute()]
self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute()
self.file_model.delete().where(self.file_model.EntryId.not_in(Ids)).execute()

def db_get_files_series(
self,
Expand Down Expand Up @@ -1438,7 +1433,6 @@ def db_update(self):
if self.type == "sonarr":
if not self.series_search:
self.model_arr_file: EpisodesModel
self.file_model: EpisodeFilesModel
_series = set()
if self.search_by_year:
series_query = self.model_arr_file.select().where(
Expand Down Expand Up @@ -1484,7 +1478,6 @@ def db_update(self):
self.db_update_single_series(db_entry=series)
else:
self.model_arr_series_file: SeriesModel
self.series_file_model: SeriesFilesModel
for series in (
self.model_arr_series_file.select()
.order_by(self.model_arr_series_file.Added.desc())
Expand All @@ -1496,7 +1489,6 @@ def db_update(self):
self.model_arr_file: MoviesModel
elif self.version == "5":
self.model_arr_file: MoviesModelv5
self.model_file: MoviesFilesModel
if self.search_by_year:
for movies in (
self.model_arr_file.select(self.model_arr_file)
Expand Down Expand Up @@ -1956,6 +1948,7 @@ def db_update_single_series(
self.model_file.Searched: searched,
self.model_file.IsRequest: request,
}

self.logger.trace("Adding %s to db: [%s][%s]", title, movieFileId, searched)
db_commands = self.model_file.insert(
Title=title,
Expand Down

0 comments on commit 080ed49

Please sign in to comment.