Skip to content

Commit

Permalink
if analytics not enabled use the metrics to display home page visits
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Sep 5, 2024
1 parent 8541d5f commit ec5b0df
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
18 changes: 13 additions & 5 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def index
@analytics.keys.size
end

metrics = LinkedData::Client::Models::Metrics.all
metrics = metrics.each_with_object(Hash.new(0)) do |h, sum|
all_metrics = LinkedData::Client::Models::Metrics.all
metrics = all_metrics.each_with_object(Hash.new(0)) do |h, sum|
h.to_hash.slice(:classes, :properties, :individuals).each { |k, v| sum[k] += v }
end
@slices = LinkedData::Client::Models::Slice.all
Expand All @@ -39,11 +39,19 @@ def index

@anal_ont_names = []
@anal_ont_numbers = []
@analytics.sort_by{|ont, count| -count}[0..4].each do |ont, count|
@anal_ont_names << ont
@anal_ont_numbers << count
if @analytics.empty?
all_metrics.sort_by{|x| -(x.classes + x.individuals)}[0..4].each do |x|
@anal_ont_names << x.links["ontology"].split('/').last
@anal_ont_numbers << x.classes + x.individuals
end
else
@analytics.sort_by{|ont, count| -count}[0..4].each do |ont, count|
@anal_ont_names << ont
@anal_ont_numbers << count
end
end


end

def set_cookies
Expand Down
8 changes: 4 additions & 4 deletions app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
%a.h5{href:"/ontologies/#{@anal_ont_names[0]}", style: "color: white !important"}
= @anal_ont_names[0]
%p
= @anal_ont_numbers[0].to_s + " " + t('visits.visits')
= format_number_abbreviated(@anal_ont_numbers[0]) + " " + (@analytics.empty? ? t('visits.count') : t('visits.visits'))
.home-bubble.home-bubble-two
%a.h5{href:"/ontologies/#{@anal_ont_names[1]}", style: "color: white !important"}
= @anal_ont_names[1]
%p
= @anal_ont_numbers[1].to_s + " " + t('visits.visits')
= format_number_abbreviated(@anal_ont_numbers[1]) + " " + (@analytics.empty? ? t('visits.count') : t('visits.visits'))
.home-bubble.home-bubble-three
%a.h5{href:"/ontologies/#{@anal_ont_names[2]}", style: "color: white !important"}
= @anal_ont_names[2]
%p
= @anal_ont_numbers[2].to_s + " " + t('visits.visits')
= format_number_abbreviated(@anal_ont_numbers[2]) + " " + (@analytics.empty? ? t('visits.count') : t('visits.visits'))
%a.home-bubble.home-bubble-four{:href => "/visits"}
.h5 ...

Expand All @@ -47,7 +47,7 @@

.home-body-container
.home-section
%h4= t('home.ontology_upload')
%h4= t('home.ontology_upload', site: portal_name)
%hr.home-section-line/
%p= t('home.ontology_upload_desc')
%p= t('home.ontology_upload_benefits', site: $SITE)
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ en:
ontology_visits: Ontology visits
name: name
visits: visits
count: concepts
ontologies_selector:
clear_selection: Clear selection
ontologies_advanced_selection: Ontologies advanced selection
Expand Down
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1474,6 +1474,7 @@ fr:
ontology_visits: Visites de l'ontologie
name: nom
visits: visites
count: concepts

ontologies_selector:
clear_selection: Effacer la sélection
Expand Down

0 comments on commit ec5b0df

Please sign in to comment.