Skip to content

Commit

Permalink
Added languages profile creation and assignment to health check.
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheus65535 committed Dec 18, 2024
1 parent c8e2894 commit 43d9d43
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion bazarr/utilities/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

This comment has been minimized.

Copy link
@mlofjard

mlofjard Dec 24, 2024

This should be an AND instead of an OR. Otherwise you need to assign your profiles to at least one series AND one movie.

This comment has been minimized.

Copy link
@morpheus65535

morpheus65535 Dec 25, 2024

Author Owner

It was the idea behind that. I'm not sure why you wouldn't have at least one series and one movies with an assigned languages profile...

This comment has been minimized.

Copy link
@mlofjard

mlofjard Dec 25, 2024

I got the warning since all my movies were "pre-bazarr" and had no profile attached yet, but the profile was being used on some series (and as the default for newly added movies).
So maybe the check should be that a profile is assigned to the "Default Language Profiles For Newly Added Shows" instead?
Or maybe I'm just overthinking it. =)

This comment has been minimized.

Copy link
@morpheus65535

morpheus65535 Dec 25, 2024

Author Owner

Haha I thought about it too but what about users who doesn't assign a default languages profile and want to do it manually?

I'll leave it like this for now and I'll see if I get the same concern by other users.

Thanks for your feedback and merry Christmas!

This comment has been minimized.

Copy link
@mlofjard

mlofjard Dec 25, 2024

Or maybe it should be both/either. Bear with me here, since english is my second language, so I might be explaining it poorly. =)

If a user is setting this up for a new empty library, and have everything configured for future additions, then the health check would trigger until at least one movie and one series had been added to the library.

So perhaps it should be something like this:

elif languages_profiles_count > 0 and ((settings.general.use_sonar and series_with_profile == 0 and future_series_has_no_profile) or (settings.general_use_radarr and movies_with_profile == 0 and future_movies_has_no_profile)): 

This comment has been minimized.

Copy link
@mlofjard

mlofjard Dec 25, 2024

I might write up a PR for it myself next week.

Thank you for a great project! And Merry christmas to you as well!

This comment has been minimized.

Copy link
@morpheus65535

morpheus65535 Dec 25, 2024

Author Owner

Sounds good to me, I'll wait for your PR.

(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

0 comments on commit 43d9d43

Please sign in to comment.