Add new route to view all RFCs the user has commented on

This commit is contained in:
Maximilian Grundke
2017-08-13 15:01:11 +02:00
parent b2344cfd97
commit 726ef31ee7
5 changed files with 19 additions and 2 deletions

View File

@ -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