Skip to content

Commit

Permalink
[build] Alternate delete method
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Sep 20, 2023
1 parent ae6347a commit d1ed225
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,10 @@ 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.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__episode_searched_state(self):
self.model_file: EpisodeFilesModel
Expand All @@ -1111,6 +1115,8 @@ def db_reset__episode_searched_state(self):
self.model_file.update(Searched=False).where(
self.model_file.Searched == True
).execute()
Ids = [id.Id for id in self.model_arr_file.select().execute()]
self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute()

def db_reset__movie_searched_state(self):
self.model_file: MoviesFilesModel
Expand All @@ -1120,6 +1126,8 @@ def db_reset__movie_searched_state(self):
self.model_file.update(Searched=False).where(
self.model_file.Searched == True
).execute()
Ids = [id.Id for id in self.model_arr_file.select().execute()]
self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute()

def db_get_files_series(
self,
Expand Down Expand Up @@ -1425,8 +1433,6 @@ def db_update(self):
if self.type == "sonarr":
if not self.series_search:
self.model_arr_file: EpisodesModel
Ids = [id.Id for id in self.model_arr_file.select().execute()]
self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute()
_series = set()
if self.search_by_year:
series_query = self.model_arr_file.select().where(
Expand Down Expand Up @@ -1472,10 +1478,6 @@ def db_update(self):
self.db_update_single_series(db_entry=series)
else:
self.model_arr_series_file: SeriesModel
Ids = [id.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()
for series in (
self.model_arr_series_file.select()
.order_by(self.model_arr_series_file.Added.desc())
Expand All @@ -1487,14 +1489,6 @@ def db_update(self):
self.model_arr_file: MoviesModel
elif self.version == "5":
self.model_arr_file: MoviesModelv5
Ids = [id.Id for id in self.model_arr_file.select().execute()]
deleted = (
self.model_file.delete().where(self.model_file.EntryId.not_in(Ids)).execute()
)
if deleted == 0:
self.logger.info("No records deleted")
elif deleted > 0:
self.logger.info("Deleted %s records", deleted)
if self.search_by_year:
for movies in (
self.model_arr_file.select(self.model_arr_file)
Expand Down Expand Up @@ -3711,6 +3705,7 @@ def run_search_loop(self) -> NoReturn:
years_index = 0
while True:
if self.loop_completed:
self.register_search_mode()
years_index = 0
timer = datetime.now()
if self.search_by_year:
Expand Down

0 comments on commit d1ed225

Please sign in to comment.