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'
|
render 'index'
|
||||||
end
|
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
|
def mark_as_solved
|
||||||
authorize!
|
authorize!
|
||||||
@request_for_comment.solved = true
|
@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.comments_count
|
||||||
td = request_for_comment.user.displayname
|
td = request_for_comment.user.displayname
|
||||||
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.created_at))
|
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
|
//- 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(last_comment.nil? ? request_for_comment.updated_at : last_comment.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)
|
= render('shared/pagination', collection: @request_for_comments)
|
@ -457,6 +457,7 @@ de:
|
|||||||
index:
|
index:
|
||||||
get_my_comment_requests: Meine Kommentaranfragen
|
get_my_comment_requests: Meine Kommentaranfragen
|
||||||
all: "Alle Kommentaranfragen"
|
all: "Alle Kommentaranfragen"
|
||||||
|
get_rfcs_with_my_comments: Kommentaranfragen die ich kommentiert habe
|
||||||
no_question: "Der Autor hat keine Frage zu dieser Anfrage gestellt."
|
no_question: "Der Autor hat keine Frage zu dieser Anfrage gestellt."
|
||||||
mark_as_solved: "Diese Frage als beantwortet markieren"
|
mark_as_solved: "Diese Frage als beantwortet markieren"
|
||||||
show_all: "Alle Anfragen anzeigen"
|
show_all: "Alle Anfragen anzeigen"
|
||||||
|
@ -478,6 +478,7 @@ en:
|
|||||||
index:
|
index:
|
||||||
all: All Requests for Comments
|
all: All Requests for Comments
|
||||||
get_my_comment_requests: My Requests for Comments
|
get_my_comment_requests: My Requests for Comments
|
||||||
|
get_rfcs_with_my_comments: Requests for Comments I have commented on
|
||||||
no_question: "The author did not enter a question for this request."
|
no_question: "The author did not enter a question for this request."
|
||||||
mark_as_solved: "Mark this question as answered"
|
mark_as_solved: "Mark this question as answered"
|
||||||
show_all: "All requests"
|
show_all: "All requests"
|
||||||
|
@ -20,6 +20,7 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
get '/my_request_for_comments', as: 'my_request_for_comments', to: 'request_for_comments#get_my_comment_requests'
|
get '/my_request_for_comments', as: 'my_request_for_comments', to: 'request_for_comments#get_my_comment_requests'
|
||||||
|
get '/my_rfc_activity', as: 'my_rfc_activity', to: 'request_for_comments#get_rfcs_with_my_comments'
|
||||||
|
|
||||||
delete '/comment_by_id', to: 'comments#destroy_by_id'
|
delete '/comment_by_id', to: 'comments#destroy_by_id'
|
||||||
put '/comments', to: 'comments#update'
|
put '/comments', to: 'comments#update'
|
||||||
|
Reference in New Issue
Block a user