forum: add /forum_topic_visits.{json,xml} endpoint.

For debugging purposes only.
This commit is contained in:
evazion
2020-01-22 21:30:00 -06:00
parent cc96f30e47
commit fcb6f96979
3 changed files with 16 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
class ForumTopicVisitsController < ApplicationController
respond_to :xml, :json
before_action :member_only
def index
@forum_topic_visits = ForumTopicVisit.where(user: CurrentUser.user).paginated_search(params)
respond_with(@forum_topic_visits)
end
end

View File

@@ -5,4 +5,10 @@ class ForumTopicVisit < ApplicationRecord
def self.prune!(user)
where("user_id = ? and last_read_at < ?", user.id, user.last_forum_read_at).delete_all
end
def self.search(params)
q = super
q = q.search_attributes(params, :user, :forum_topic_id, :last_read_at)
q.apply_default_order(params)
end
end