Add new route to view all RFCs the user has commented on
This commit is contained in:
@@ -22,6 +22,20 @@ class RequestForCommentsController < ApplicationController
|
||||
render 'index'
|
||||
end
|
||||
|
||||
def get_rfcs_with_my_comments
|
||||
@search = RequestForComment
|
||||
.joins(:comments)
|
||||
.where(comments: {user_id: current_user.id})
|
||||
.group('request_for_comments.id')
|
||||
.joins(:comments)
|
||||
.group('request_for_comments.id')
|
||||
.select('request_for_comments.*, max(comments.updated_at) as last_comment')
|
||||
.order('last_comment DESC')
|
||||
.search(params[:q])
|
||||
@request_for_comments = @search.result.paginate(page: params[:page])
|
||||
render 'index'
|
||||
end
|
||||
|
||||
def mark_as_solved
|
||||
authorize!
|
||||
@request_for_comment.solved = true
|
||||
|
@@ -37,7 +37,7 @@ h1 = RequestForComment.model_name.human(count: 2)
|
||||
td = request_for_comment.comments_count
|
||||
td = request_for_comment.user.displayname
|
||||
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.created_at))
|
||||
- last_comment = request_for_comment.comments.order('created_at DESC').first
|
||||
td = t('shared.time.before', time: distance_of_time_in_words_to_now(last_comment.nil? ? request_for_comment.updated_at : last_comment.updated_at))
|
||||
//- last_comment = request_for_comment.last_comment || request_for_comment.comments.order('created_at DESC').try(:first).try(:updated_at)
|
||||
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.last_comment))
|
||||
|
||||
= render('shared/pagination', collection: @request_for_comments)
|
Reference in New Issue
Block a user