Added limit param for activity stream API.

This commit is contained in:
Martin Edenhofer 2012-04-29 23:37:49 +02:00
parent e60163ed30
commit 9208927be9
4 changed files with 9 additions and 5 deletions

View file

@ -16,7 +16,7 @@ class App.DashboardActivityStream extends App.Controller
type: 'GET',
url: '/activity_stream',
data: {
limit: 10,
limit: @limit,
}
processData: true,
# data: JSON.stringify( view: @view ),

View file

@ -30,6 +30,9 @@ class Index extends App.Controller
side: {
activity_stream: {
controller: App.DashboardActivityStream,
params: {
limit: 8,
},
},
rss_atom: {
controller: App.DashboardRss,

View file

@ -367,7 +367,7 @@ class TicketOverviewsController < ApplicationController
# GET /activity_stream
# GET /activity_stream.json
def activity_stream
activity_stream = History.activity_stream(current_user)
activity_stream = History.activity_stream(current_user, params[:limit])
# get related users
users = {}

View file

@ -17,14 +17,15 @@ class History < ActiveRecord::Base
return history
end
def self.activity_stream(user)
def self.activity_stream(user, limit = 10)
# g = Group.where( :active => true ).joins(:users).where( 'users.id' => user.id )
# stream = History.select("distinct(histories.o_id), created_by_id, history_attribute_id, history_type_id, history_object_id, value_from, value_to").
# where( :history_type_id => History::Type.where( :name => ['created', 'updated']) ).
stream = History.select("distinct(histories.o_id), created_by_id, history_type_id, history_object_id").
where( :history_object_id => History::Object.where( :name => 'Ticket').first.id ).
where( :history_type_id => History::Type.where( :name => ['created', 'updated']) ).
where( :history_type_id => History::Type.where( :name => ['updated']) ).
order('created_at DESC, id DESC').
limit(10)
limit(limit)
datas = []
stream.each do |item|
data = item.attributes