2017-08-02 23:27:05 +08:00
|
|
|
module ClientApi
|
|
|
|
class ActivitiesController < ApplicationController
|
|
|
|
|
|
|
|
def index
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render template: '/client_api/activities/index',
|
|
|
|
status: :ok,
|
2017-08-03 17:17:09 +08:00
|
|
|
locals: activities_vars
|
2017-08-02 23:27:05 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-08-03 17:17:09 +08:00
|
|
|
def activities_vars
|
2017-12-14 21:02:40 +08:00
|
|
|
page = (params[:page] || 1).to_i
|
|
|
|
activities = current_user
|
|
|
|
.last_activities
|
|
|
|
.page(page)
|
|
|
|
.per(Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
|
|
|
|
{
|
|
|
|
activities: activities,
|
|
|
|
page: page,
|
2018-01-03 20:48:59 +08:00
|
|
|
more: !activities.last_page?,
|
2017-12-14 21:02:40 +08:00
|
|
|
timezone: current_user.time_zone
|
|
|
|
}
|
2017-08-02 23:27:05 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|