From 18c30be82ea2b4cb98b91f234e8e17720b0384fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Thu, 28 Sep 2023 12:16:18 +0200 Subject: [PATCH] Clean up helper --- app/helpers/home_helper.rb | 75 -------------------------------------- 1 file changed, 75 deletions(-) diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb index 0a04cd5b..38f08842 100644 --- a/app/helpers/home_helper.rb +++ b/app/helpers/home_helper.rb @@ -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}" @@ -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 @@ -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