Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sles subscriptions count #167

Merged
merged 5 commits into from
Mar 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions lib/tronto/monitoring/monitoring.ex
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,24 @@ defmodule Tronto.Monitoring do
|> Repo.preload(checks_results: :host)
end

@spec get_all_sles_subscriptions :: [SlesSubscriptionReadModel.t()]
def get_all_sles_subscriptions,
do: SlesSubscriptionReadModel |> Repo.all() |> Repo.preload(:host)
@spec get_all_sles_subscriptions :: non_neg_integer() | {:error, any}
def get_all_sles_subscriptions do
query =
from s in SlesSubscriptionReadModel,
where: s.identifier == "SLES_SAP",
select: count()

case Repo.one(query) do
{:error, _} = error ->
error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repo.one returns nil or the entity, this case will never match

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup 🙏


nil ->
0

subscription_count ->
subscription_count
end
end

@spec get_all_sap_systems :: [SapSystemReadModel.t()]
def get_all_sap_systems do
Expand Down