From 43d9d43224c84609a4fbd050c8d82e9500743a68 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Wed, 18 Dec 2024 16:34:29 -0500 Subject: Added languages profile creation and assignment to health check. --- bazarr/utilities/health.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3