Skip to content

Commit

Permalink
Fix: Watch button count and state (#838)
Browse files Browse the repository at this point in the history
* include all when loading the user, to make sure we get ontologies acronyms in usrer.subscription list

* fix watch button count
  • Loading branch information
Bilelkihal authored Nov 8, 2024
1 parent 43e4d44 commit 10237aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,9 @@ def admin_block(ontology: @ontology, user: session[:user], class_css: "admin-bor
end

def subscribed_to_ontology?(ontology_acronym, user)
user = LinkedData::Client::Models::User.find(user.username, {include: 'subscription'}) if user.subscription.nil?
user = LinkedData::Client::Models::User.find(user.username, {include: 'all'}) if user.subscription.nil?
return false if user.subscription.nil? or user.subscription.empty?
user.subscription.each do |sub|
#sub = {ontology: ontology_acronym, notification_type: "NOTES"}
sub_ont_acronym = sub[:ontology] ? sub[:ontology].split('/').last : nil # make sure we get the acronym, even if it's a full URI
return true if sub_ont_acronym == ontology_acronym
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/ontologies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ def ontology_depiction_card

def count_subscriptions(ontology_id)
ontology_id = ontology_id.split('/').last
users = LinkedData::Client::Models::User.all(include: 'subscription', display_context: false, display_links: false)
users = LinkedData::Client::Models::User.all(include: 'all', display_context: false, display_links: false)
users.select { |u| u.subscription.find { |s| s.ontology && s.ontology.split('/').last.eql?(ontology_id) } }.count
end

Expand Down

0 comments on commit 10237aa

Please sign in to comment.