diff options
author | morpheus65535 <[email protected]> | 2024-12-18 16:34:29 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2024-12-18 16:34:29 -0500 |
commit | 43d9d43224c84609a4fbd050c8d82e9500743a68 (patch) | |
tree | 20eb698a5da225ec5da9eb7c48a31ee65011c9bb | |
parent | c8e2894b2ba033a11eb52ccd4f50186da74a90d8 (diff) | |
download | bazarr-43d9d43224c84609a4fbd050c8d82e9500743a68.tar.gz bazarr-43d9d43224c84609a4fbd050c8d82e9500743a68.zip |
Added languages profile creation and assignment to health check.v1.4.6-beta.33
-rw-r--r-- | bazarr/utilities/health.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/bazarr/utilities/health.py b/bazarr/utilities/health.py index c1d3a6a3d..84a313cf0 100644 --- a/bazarr/utilities/health.py +++ b/bazarr/utilities/health.py @@ -2,8 +2,11 @@ import json +from sqlalchemy import func + from app.config import settings -from app.database import TableShowsRootfolder, TableMoviesRootfolder, TableLanguagesProfiles, database, select +from app.database import (TableShowsRootfolder, TableMoviesRootfolder, TableLanguagesProfiles, database, select, + TableShows, TableMovies) from app.event_handler import event_stream from .path_mappings import path_mappings from sonarr.rootfolder import check_sonarr_rootfolder @@ -66,4 +69,19 @@ def get_health_issues(): else: languages_profile_ids.append(items['id']) + # check if there's at least one languages profile created + languages_profiles_count = database.execute(select(func.count(TableLanguagesProfiles.profileId))).scalar() + series_with_profile = database.execute(select(func.count(TableShows.sonarrSeriesId)) + .where(TableShows.profileId.is_not(None))).scalar() + movies_with_profile = database.execute(select(func.count(TableMovies.radarrId)) + .where(TableMovies.profileId.is_not(None))).scalar() + if languages_profiles_count == 0: + health_issues.append({'object': 'Missing languages profile', + 'issue': 'You must create at least one languages profile and assign it to your content.'}) + elif languages_profiles_count > 0 and ((settings.general.use_sonarr and series_with_profile == 0) or + (settings.general.use_radarr and movies_with_profile == 0)): + health_issues.append({'object': 'No assigned languages profile', + 'issue': 'Although you have created at least one languages profile, you must assign it ' + 'to your content.'}) + return health_issues |