From 35decd47069df549d0739f0843c9a66d6e26556a Mon Sep 17 00:00:00 2001 From: KarishmaVanwari Date: Wed, 22 Jun 2022 16:56:11 +0530 Subject: [PATCH] Fixes #11203: Refined Information hierarchy on profile page --- app/models/tag.rb | 17 ++++++++++++----- app/views/tag/_profileCard.html.erb | 3 +-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index a14b052b7c..2db8d6ec26 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -93,11 +93,18 @@ def self.find_top_nodes_by_type(tagname:, type: 'wiki', limit: 10) end # finds recent nodes - should drop "limit" and allow use of chainable .limit() - def self.find_nodes_by_type(tagnames, type = 'note', limit = 10) - nodes = Node.where(status: 1, type: type) - .includes(:tag) - .references(:term_data) - .where('term_data.name IN (?)', tagnames) + def self.find_nodes_by_type(tagnames, type = 'note', limit = 10, author_id = -1) + if author_id != -1 + nodes = Node.where(status: 1, type: type, uid: author_id) + .includes(:tag) + .references(:term_data) + .where('term_data.name IN (?)', tagnames) + else + nodes = Node.where(status: 1, type: type) + .includes(:tag) + .references(:term_data) + .where('term_data.name IN (?)', tagnames) + end # .select(%i[node.nid node.status node.type community_tags.nid community_tags.tid term_data.name term_data.tid]) # above select could be added later for further optimization order = 'node_revisions.timestamp DESC' diff --git a/app/views/tag/_profileCard.html.erb b/app/views/tag/_profileCard.html.erb index 9bae09bc05..8ca58a7007 100644 --- a/app/views/tag/_profileCard.html.erb +++ b/app/views/tag/_profileCard.html.erb @@ -7,7 +7,7 @@
- <% Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3).each do |node| %> + <% Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3, author_id = @profile_user.id).each do |node| %> <% end %>