Skip to content

Commit

Permalink
Clean up helper
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Sep 28, 2023
1 parent 7e80c06 commit 18c30be
Showing 1 changed file with 0 additions and 75 deletions.
75 changes: 0 additions & 75 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,6 @@ def review_issue_links(paper)
end
end

def checklist_activity(paper)
return "No activity" if paper.activities.empty?
return "No activity" if paper.activities['issues']['commenters'].empty?

capture do
if !paper.activities['issues']['comments'].empty?
if paper.activities['issues']['last_edits'] && paper.activities['issues']['last_edits'].keys.any?
non_editorial_bot_activities = paper.activities['issues']['last_edits'].select {|user, time| user != Rails.application.settings["bot_username"]}
return "No activity" if non_editorial_bot_activities.empty?
user, time = non_editorial_bot_activities.first
concat(content_tag(:span, image_tag(avatar(user), size: "24x24", class: "avatar", title: user), class: "activity-avatar"))
concat(content_tag(:span, style: "") do
concat(content_tag(:span, "#{time_ago_in_words(time)} ago".html_safe, class: "time"))
end)
else
return "No activity"
end
end
end
end

def sort_activity(sort_order)
track_param = params[:track_id].present? ? "track_id=#{params[:track_id]}&" : ""
request_path = "#{request.path}?#{track_param}"
Expand Down Expand Up @@ -117,50 +96,6 @@ def comment_activity(paper)
end
end

def card_activity(paper)
return "No activity" if paper.activities.empty?
return "No activity" if paper.activities['issues']['commenters'].empty?
capture do
if !paper.activities['issues']['comments'].empty?
if paper.activities['issues']['last_edits'] && paper.activities['issues']['last_edits'].keys.any?
concat content_tag(:strong, "Recent activity", style: "padding-bottom: 5px;")
paper.activities['issues']['last_edits'].each do |user,time|
concat(content_tag(:p, "Checklist edit by #{user}, #{time_ago_in_words(time)} ago", style: "padding: 0px; margin: 0px 0px 10px 0px;"))
end
end
concat content_tag(:strong, "Recent comments", style: "padding-bottom: 5px;")
paper.activities['issues']['comments'].each do |comment|
concat(content_tag(:p, truncate(comment['comment'], length: 120), style: "padding: 0px; margin-bottom: 0px;"))
concat(content_tag(:p, "#{time_ago_in_words(comment['commented_at']).capitalize} ago (@#{comment['author']}). #{comment_link(comment)}".html_safe, style: "padding: 0px; margin: 0px 0px 10px 0px; font-style: italic;"))
end
end
end
end

def last_comment_for(paper)
return "No recent comments" unless paper.activities['issues']
comments = paper.activities['issues']['comments']
last_comment = comments.sort_by {|c| c['commented_at']}.last

if last_comment
"#{github_user(last_comment['author'])} #{time_ago_in_words(last_comment ['commented_at'])} ago, #{comment_link(last_comment)}".html_safe
else
return "No recent comments"
end
end

def commenters_for(paper)

end

def stale_link
link_to("Most stale".html_safe, "#{request.path}?order=asc")
end

def fresh_link
link_to("Least stale".html_safe, "#{request.path}?order=desc")
end

def comment_link(comment)
link_to("View comment »".html_safe, comment['comment_url'], target: "_blank", title: comment['comment'])
end
Expand All @@ -172,14 +107,4 @@ def github_user_link(username)
def github_user(username)
link_to("@#{username}", github_user_link(username))
end

def activites_shortcut_for(paper)
activities = paper.activities['issues']
comments = activities['pre-review']['comments'] + activities['review']['comments']
"Last comment by @arfon 3 hours ago (expand)"
end

def linked_reviewers(paper)
paper.reviewers.map { |reviewer| github_user(reviewer.gsub('@', '')) }.join(', ').html_safe
end
end

0 comments on commit 18c30be

Please sign in to comment.