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
|
|
|
|
last_activity_id = params[:from].to_i || 0
|
|
|
|
per_page = Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT
|
|
|
|
activities = current_user.last_activities(last_activity_id, per_page + 1)
|
|
|
|
more = activities.length > per_page
|
|
|
|
{ activities: activities, more: more }
|
2017-08-02 23:27:05 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|