|
|
|
@ -388,15 +388,14 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def show
|
|
|
|
|
pre_count = 10 #limit
|
|
|
|
|
case params[:type]
|
|
|
|
|
when "1"
|
|
|
|
|
if @user == User.current
|
|
|
|
|
activity = Activity.where('user_id = ?', User.current.id).order('id desc')
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
@activity_count = activity.count
|
|
|
|
|
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
|
@offset ||= @activity_pages.offset
|
|
|
|
|
@activity = activity.offset(@offset).limit(@limit)
|
|
|
|
|
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
|
|
|
|
|
@activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all
|
|
|
|
|
@state = 1
|
|
|
|
|
end
|
|
|
|
|
when "2"
|
|
|
|
@ -405,28 +404,24 @@ class UsersController < ApplicationController
|
|
|
|
|
message = JournalsForMessage.reference_message(@user.id)
|
|
|
|
|
message += Journal.reference_message(@user.id)
|
|
|
|
|
end
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
@activity_count = message.size
|
|
|
|
|
@info_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
|
@offset ||= @info_pages.offset
|
|
|
|
|
|
|
|
|
|
@info_pages = Paginator.new @activity_count, pre_count, params['page']
|
|
|
|
|
messages = message.sort {|x,y| y.created_on <=> x.created_on }
|
|
|
|
|
|
|
|
|
|
@message = messages[@offset, @limit]
|
|
|
|
|
@message = messages[@info_pages.offset, @info_pages.per_page]
|
|
|
|
|
@state = 2
|
|
|
|
|
else
|
|
|
|
|
where_condition = nil;#"act_type <> 'JournalsForMessage'"
|
|
|
|
|
where_condition = "act_type <> 'JournalsForMessage'"
|
|
|
|
|
if @user == User.current
|
|
|
|
|
watcher = User.watched_by(@user)
|
|
|
|
|
watcher.push(User.current)
|
|
|
|
|
activity = Activity.where('user_id in (?)', watcher).order('id desc')
|
|
|
|
|
activity = Activity.where(where_condition).where('user_id in (?)', watcher).order('id desc')
|
|
|
|
|
else
|
|
|
|
|
activity = Activity.where('user_id = ?', @user.id).order('id desc')
|
|
|
|
|
activity = Activity.where(where_condition).where('user_id = ?', @user.id).order('id desc')
|
|
|
|
|
end
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
@activity_count = activity.count
|
|
|
|
|
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
|
|
|
|
@offset ||= @activity_pages.offset
|
|
|
|
|
@activity = activity.offset(@offset).limit(@limit)
|
|
|
|
|
@activity_pages = Paginator.new @activity_count, pre_count, params['page']
|
|
|
|
|
@activity = activity.offset(@activity_pages.offset).limit(@activity_pages.per_page).all
|
|
|
|
|
@state = 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|