Просмотр исходного кода

Added limit param for activity stream API.

Martin Edenhofer 13 лет назад
Родитель
Сommit
9208927be9

+ 1 - 1
app/assets/javascripts/app/controllers/_dashboard/activity_stream.js.coffee

@@ -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 ),

+ 3 - 0
app/assets/javascripts/app/controllers/dashboard.js.coffee

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

+ 1 - 1
app/controllers/ticket_overviews_controller.rb

@@ -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 = {}

+ 4 - 3
app/models/history.rb

@@ -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