Skip to content

Commit

Permalink
Fixes publiclab#11203: Refined Information hierarchy on profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
KarishmaVanwari committed Jun 22, 2022
1 parent 5e44070 commit 35decd4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
17 changes: 12 additions & 5 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 1 addition & 2 deletions app/views/tag/_profileCard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<p class="posted-by-links"><a href="/tag/<%= tag.name %>"><%= pluralize(Tag.follower_count(tag.name), 'person') %> discussing</a></p>
</div>
<div class="card-body">
<% 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| %>
<div class="posted-by-links">
<% if node.main_image %>
<img class="rounded-circle" id="profile-photo" style="width:20px; height:20px; margin-right:8px; display: inline-block;" src="<%= node.main_image.path(:default) %>" />
Expand All @@ -17,7 +17,6 @@
<div class="circle"></div>
<% end %>
<a class="post-title" <% if @widget %>target="_blank"<% end %> href="<%= node.path %>"><%= (node.type == 'note') ? node.title : node.latest.title %></a>
by <a href="/profile/<%= node.author.name %>" class="text-decoration-none">@<%= node.author.name %></a>
</div>
<% end %>
</div>
Expand Down

0 comments on commit 35decd4

Please sign in to comment.