Recent viewed are available at initial load.
This commit is contained in:
parent
202f0529f9
commit
87c91152a7
3 changed files with 8 additions and 5 deletions
|
@ -19,7 +19,7 @@ curl http://localhost/api/v1/recent_viewed -v -u #{login}:#{password} -H "Conten
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
recent_viewed = RecentView.list_fulldata( current_user, 10 )
|
recent_viewed = RecentView.list_full( current_user, 10 )
|
||||||
|
|
||||||
# return result
|
# return result
|
||||||
render :json => recent_viewed
|
render :json => recent_viewed
|
||||||
|
|
|
@ -13,6 +13,9 @@ module ExtraCollection
|
||||||
collections[ OnlineNotification.to_app_model ] = OnlineNotification.list(user, 20)
|
collections[ OnlineNotification.to_app_model ] = OnlineNotification.list(user, 20)
|
||||||
assets = ApplicationModel.assets_of_object_list(collections[ OnlineNotification.to_app_model ], assets)
|
assets = ApplicationModel.assets_of_object_list(collections[ OnlineNotification.to_app_model ], assets)
|
||||||
|
|
||||||
|
collections[ RecentView.to_app_model ] = RecentView.list(user, 10)
|
||||||
|
assets = RecentView.assets_of_object_list(collections[ RecentView.to_app_model ], assets)
|
||||||
|
|
||||||
collections[ Role.to_app_model ] = []
|
collections[ Role.to_app_model ] = []
|
||||||
Role.all.each {|item|
|
Role.all.each {|item|
|
||||||
assets = item.assets(assets)
|
assets = item.assets(assets)
|
||||||
|
|
|
@ -46,20 +46,20 @@ class RecentView < ApplicationModel
|
||||||
list
|
list
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.list_fulldata( user, limit = 10 )
|
def self.list_full( user, limit = 10 )
|
||||||
recent_viewed = self.list( user, limit )
|
recent_viewed = self.list( user, limit )
|
||||||
|
|
||||||
# get related object
|
# get related object
|
||||||
assets = ApplicationModel.assets_of_object_list(recent_viewed)
|
assets = ApplicationModel.assets_of_object_list(recent_viewed)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
:recent_viewed => recent_viewed,
|
:stream => recent_viewed,
|
||||||
:assets => assets,
|
:assets => assets,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def notify_clients
|
def notify_clients
|
||||||
data = RecentView.list_fulldata( User.find(self.created_by_id), 10 )
|
data = RecentView.list_full( User.find(self.created_by_id), 10 )
|
||||||
Sessions.send_to(
|
Sessions.send_to(
|
||||||
self.created_by_id,
|
self.created_by_id,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue