Skip to content

Commit

Permalink
handle the case where user counts is not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Jan 24, 2025
1 parent d46f0a2 commit dee7aca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
7 changes: 6 additions & 1 deletion app/helpers/admin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ def action_button(name, link, method: :post, class_style: 'btn btn-link')
end

def user_count
user_count = LinkedData::Client::HTTP.get(Admin::LogsController::USERS_QUERY_COUNT.dup, {}, raw: true)
begin
user_count = LinkedData::Client::HTTP.get(Admin::LogsController::USERS_QUERY_COUNT.dup, {}, raw: true)
rescue
user_count = '[]'
end

user_count = MultiJson.load(user_count)
return [] if user_count.is_a?(Hash) && user_count['errors']

Expand Down
15 changes: 8 additions & 7 deletions app/views/admin/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
- else
= render 'analytics'

%div
%div.my-2
%div.card.p-2
= chart_component(title: 'Users API usage the last 30 days', type: 'bar',
labels: @users_count.keys,
datasets: visits_chart_dataset_array({'SPARQL Calls': @users_count.values}),
index_axis: 'y')
- unless @users_count.empty?
%div
%div.my-2
%div.card.p-2
= chart_component(title: 'Users API usage the last 30 days', type: 'bar',
labels: @users_count.keys,
datasets: visits_chart_dataset_array({'SPARQL Calls': @users_count.values}),
index_axis: 'y')
- t.item_content do
= render 'main'
- t.item_content do
Expand Down

0 comments on commit dee7aca

Please sign in to comment.