You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by as...@apache.org on 2008/07/02 02:53:18 UTC

svn commit: r673246 - in /ode/sandbox/singleshot: ./ app/controllers/ app/models/ app/views/activity/ config/ db/migrate/ public/stylesheets/ spec/models/

Author: assaf
Date: Tue Jul  1 17:53:17 2008
New Revision: 673246

URL: http://svn.apache.org/viewvc?rev=673246&view=rev
Log:
Added more 3rd party dependencies in NOTICE file.
Activity stream now using will_paginate and faster query for graph (no dependens loaded).

Modified:
    ode/sandbox/singleshot/NOTICE
    ode/sandbox/singleshot/app/controllers/activity_controller.rb
    ode/sandbox/singleshot/app/controllers/sparklines_controller.rb
    ode/sandbox/singleshot/app/models/activity.rb
    ode/sandbox/singleshot/app/views/activity/index.html.erb
    ode/sandbox/singleshot/config/environment.rb
    ode/sandbox/singleshot/db/migrate/20080506015153_create_activities.rb
    ode/sandbox/singleshot/public/stylesheets/default.css
    ode/sandbox/singleshot/spec/models/activity_spec.rb

Modified: ode/sandbox/singleshot/NOTICE
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/NOTICE?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/NOTICE (original)
+++ ode/sandbox/singleshot/NOTICE Tue Jul  1 17:53:17 2008
@@ -22,9 +22,39 @@
 AssertSelect, Copyright (c) 2006 Assaf Arkin
 http://rspec.info/
 
+rest-open-uri, copyright of Leonard Richardson.
+http://rubyforge.org/projects/rest-open-uri/
+
+RMagick, copyright of Timothy P. Hunter, licensed under MIT license.
+http://rmagick.rubyforge.org/
+
 Sparklines, copyright of Geoffrey Grosenbach, licensed under MIT license.
 http://nubyonrails.com/pages/sparklines
 
+Acts As Ferret, copyright of Kasper Weibel Nielsen-Refs (original author) and
+Jens Kraemer, licensed under MIT license.
+http://actsasferret.rubyforge.org/
+
+Ferret, copyright of Dave Balmain, licensed under MIT license.
+http://ferret.davebalmain.com/trac/
+
+Annotate Models, copyright of Cuong Tran, licensed under MIT license.
+http://annotate-models.rubyforge.org/
+
+Faker, copyright of Benjamin Curtis, licensed under MIT license.
+http://faker.rubyforge.org/
+
+SQLite Ruby, copyright of Jamis Buck, licensed under BSD license.
+http://sqlite-ruby.rubyforge.org/
+
+Thin, copyright of Marc-Andre Cournoyer, with MIT license but supposedly
+under Ruby license with some GPL code thrown in.  Not a runtime dependency.
+http://code.macournoyer.com/thin/
+
+Will Paginate, copyright of PJ Hyett and Mislav Marohnić, licensed under MIT
+license.
+http://errtheblog.com/posts/56-im-paginating-again
+
 Silk icon set, copyright of Mark James, licensed under the Creative Commons
 Attribution 2.5 License.
 http://www.famfamfam.com/lab/icons/silk/

Modified: ode/sandbox/singleshot/app/controllers/activity_controller.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/activity_controller.rb?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/activity_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/activity_controller.rb Tue Jul  1 17:53:17 2008
@@ -8,14 +8,13 @@
     @alternate = { Mime::HTML=>activity_url,
                    Mime::ATOM=>formatted_activity_url(:format=>:atom, :access_key=>authenticated.access_key),
                    Mime::ICS=>formatted_activity_url(:format=>:ics, :access_key=>authenticated.access_key) }
+    @activities = Activity.for_stakeholder(authenticated).with_dependents.paginate(:page=>params['page'], :per_page=>50)
     respond_to do |want|
       want.html do
         @graph = Activity.for_stakeholder(authenticated).for_dates(Date.current - 1.month)
-        yesterday = Date.yesterday
-        @activities = @graph[0,50]
       end
-      want.atom { @activities = Activity.for_stakeholder(authenticated).scoped(:limit=>50) }
-      want.ics  { @activities = Activity.for_stakeholder(authenticated).scoped(:limit=>50) }
+      want.atom
+      want.ics
     end
   end
 

Modified: ode/sandbox/singleshot/app/controllers/sparklines_controller.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/sparklines_controller.rb?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/sparklines_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/sparklines_controller.rb Tue Jul  1 17:53:17 2008
@@ -1,7 +1,6 @@
 # Deadline sparkline adapted from Sparklines, 
 # Copyright (c) 2005 Geoffrey Grosenbach boss@topfunky.com
 
-
 class Sparklines
 
   ## Creates a deadline sparkline.

Modified: ode/sandbox/singleshot/app/models/activity.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/activity.rb?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/activity.rb (original)
+++ ode/sandbox/singleshot/app/models/activity.rb Tue Jul  1 17:53:17 2008
@@ -1,3 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
 # == Schema Information
 # Schema version: 20080621023051
 #
@@ -17,14 +33,18 @@
   validates_presence_of :task
   validates_presence_of :name
 
-  def readonly?
+  def readonly? #:nodoc:
     !new_record?
   end
 
+  # Returns activities from all tasks associated with this stakeholder.
   named_scope :for_stakeholder, lambda { |person|
-    { :joins=>'JOIN stakeholders AS involved ON involved.task_id=tasks.id',
+    { :joins=>'JOIN stakeholders AS involved ON involved.task_id=activities.task_id',
       :conditions=>["involved.person_id=? AND involved.role != 'excluded'", person.id],
-      :include=>[:task, :person], :order=>'activities.created_at DESC' } }
+      :order=>'activities.created_at DESC', :group=>'activities.task_id, activities.person_id, activities.name' } }
+
+  named_scope :with_dependents, :include=>[:task, :person]
+
   named_scope :for_dates, lambda { |range|
     case range
     when Date

Modified: ode/sandbox/singleshot/app/views/activity/index.html.erb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activity/index.html.erb?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/activity/index.html.erb (original)
+++ ode/sandbox/singleshot/app/views/activity/index.html.erb Tue Jul  1 17:53:17 2008
@@ -10,3 +10,4 @@
     </li>
   <% end %>
 </ol>
+<%= will_paginate @activities %>

Modified: ode/sandbox/singleshot/config/environment.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/environment.rb?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/environment.rb (original)
+++ ode/sandbox/singleshot/config/environment.rb Tue Jul  1 17:53:17 2008
@@ -26,10 +26,12 @@
   # config.gem "bj"
   # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
   # config.gem "aws-s3", :lib => "aws/s3"
-  config.gem 'rest-open-uri',   :version=>'1.0.0'
-  config.gem 'rmagick',         :version=>'2.5.1'
-  config.gem 'sparklines',      :version=>'0.5.1'
-  config.gem 'acts_as_ferret',  :version=>'0.4.3'
+  config.gem 'rest-open-uri',                   :version=>'1.0.0'
+  config.gem 'rmagick', :lib=>'RMagick',        :version=>'2.5.1'
+  config.gem 'sparklines',                      :version=>'0.5.1'
+  config.gem 'acts_as_ferret',                  :version=>'0.4.3'
+  config.gem 'mislav-will_paginate', :lib=>'will_paginate',
+    :source=>'http://gems.github.com',          :version=>'2.3.2'
 
   # Only load the plugins named here, in the order given. By default, all plugins 
   # in vendor/plugins are loaded in alphabetical order.

Modified: ode/sandbox/singleshot/db/migrate/20080506015153_create_activities.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/db/migrate/20080506015153_create_activities.rb?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/db/migrate/20080506015153_create_activities.rb (original)
+++ ode/sandbox/singleshot/db/migrate/20080506015153_create_activities.rb Tue Jul  1 17:53:17 2008
@@ -1,3 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
 class CreateActivities < ActiveRecord::Migration
   def self.up
     create_table  'activities' do |t|

Modified: ode/sandbox/singleshot/public/stylesheets/default.css
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/public/stylesheets/default.css?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/public/stylesheets/default.css (original)
+++ ode/sandbox/singleshot/public/stylesheets/default.css Tue Jul  1 17:53:17 2008
@@ -400,6 +400,22 @@
 }
 
 
+/** Navigation **/
+
+div.pagination {
+  margin: 0 auto 0 auto;
+  text-align: center;
+}
+div.pagination a {
+  padding: 0.3em;
+  border: 1px solid #ccc;
+}
+div.pagination a:hover {
+  border: 1px solid #055da4;
+}
+div.pagination span {
+  padding: 0.3em;
+}
 
 /** Footer **/
 

Modified: ode/sandbox/singleshot/spec/models/activity_spec.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/spec/models/activity_spec.rb?rev=673246&r1=673245&r2=673246&view=diff
==============================================================================
--- ode/sandbox/singleshot/spec/models/activity_spec.rb (original)
+++ ode/sandbox/singleshot/spec/models/activity_spec.rb Tue Jul  1 17:53:17 2008
@@ -1,3 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
 require File.dirname(__FILE__) + '/../spec_helper'
 require File.dirname(__FILE__) + '/helper'
 
@@ -23,19 +39,19 @@
     end
 
     it 'should be required' do
-      Activity.create(:person=>person('person'), :action=>'created').should have(1).error_on(:task)
+      Activity.create(:person=>person('person'), :name=>'created').should have(1).error_on(:task)
     end
   end
 
-  describe 'action' do
+  describe 'name' do
     it 'should be part of activity' do
       Task.create! defaults
-      Activity.last.action.should == 'created'
+      Activity.last.name.should == 'created'
     end
 
     it 'should be required' do
       Task.create! defaults
-      Activity.create(:person=>person('person'), :task=>Task.last).should have(1).error_on(:action)
+      Activity.create(:person=>person('person'), :task=>Task.last).should have(1).error_on(:name)
     end
   end
 
@@ -46,20 +62,21 @@
   
   it 'should be read only' do
     Task.create! defaults
-    lambda { Activity.last.update_attributes! :action=>'updated' }.should raise_error(ActiveRecord::ReadOnlyRecord)
+    lambda { Activity.last.update_attributes! :name=>'updated' }.should raise_error(ActiveRecord::ReadOnlyRecord)
   end
 
-  it 'should delete when destroying task' do
+  it 'should be removed when destroying task' do
     Task.create! defaults
     lambda { Task.last.destroy }.should change(Activity, :count).to(0)
   end
 
-  it 'should delete when destroying person' do
+  it 'should be removed when destroying person' do
     Task.create! defaults(:creator=>person('creator'))
     lambda { person('creator').destroy }.should change(Activity, :count).to(0)
   end
 
 
+
   describe 'for_dates' do
     it 'should return activities in date range' do
       now = Time.zone.now
@@ -77,50 +94,40 @@
 
 
   describe 'for_stakeholder' do
-
-    it 'should return activities for tasks associated with person' do
-      for role in Stakeholder::ALL_ROLES - ['excluded_owners']
-        Task.create! defaults.merge(Task::ACCESSOR_FROM_ROLE[role]=>person('person'))
-      end
-      Activity.for_stakeholder(person('person')).map(&:task).uniq.size.should == Stakeholder::ALL_ROLES.size - 1
-    end
-
-    it 'should not return activities for excluded owners' do
-      Task.create! defaults.merge(:excluded_owners=>person('person'))
-      Activity.for_stakeholder(person('person')).should be_empty
+    it 'should return activities from all tasks associated with stakeholder' do
+      Task.create! defaults(:creator=>person('person'))
+      Task.create! defaults(:owner=>person('person'))
+      Task.create! defaults(:observers=>person('person'))
+      Activity.for_stakeholder(person('person')).map(&:task).uniq.size.should == 3
     end
 
-    it 'should not return activities for other stakeholders' do
-      Task.create! defaults.merge(:status=>'reserved', :potential_owners=>person('other'))
+    it 'should not return activities for excluded owner' do
+      Task.create! defaults(:excluded_owners=>person('person'))
       Activity.for_stakeholder(person('person')).should be_empty
     end
 
-    it 'should return activities for tasks with visible status' do
-      for status in Task::STATUSES - ['reserved']
-        task_with_status status, :potential_owners=>person('person')
-      end
-      Activity.for_stakeholder(person('person')).map(&:task).uniq.size.should == Task::STATUSES.size - 1
+    it 'should not return activities not relevant to stakeholder' do
+      Task.create! defaults(:creator=>person('creator'))
+      Task.create! defaults(:owner=>person('owner'))
+      Activity.for_stakeholder(person('creator')).first.task.should == Task.first
+      Activity.for_stakeholder(person('owner')).last.task.should == Task.last
     end
 
-    it 'should not return activities for reserved tasks' do
-      Task.create! defaults.merge(:status=>'reserved', :potential_owners=>person('person'))
-      Activity.for_stakeholder(person('person')).should be_empty
+    it 'should order activities from most recent to last' do
+      Task.create! defaults(:creator=>person('person'))
+      Activity.update_all ['created_at=?', Time.zone.now - 5.seconds]
+      Task.create! defaults(:owner=>person('person'))
+      activities = Activity.for_stakeholder(person('person'))
+      activities.first.created_at.should > activities.last.created_at
     end
 
-    it 'should return all activities for a visible task' do
-      Task.create! defaults.merge(:creator=>person('creator'))
-      Task.last.update_attributes! :owner=>person('owner')
-      Activity.for_stakeholder(person('creator')).should == Activity.for_stakeholder(person('owner'))
-      Activity.for_stakeholder(person('creator')).map(&:action).should include('created', 'is owner of')
-      Activity.for_stakeholder(person('owner')).map(&:person).should include(person('creator'), person('owner'))
+    it 'should not return the same activity twice' do
+      Task.create! defaults(:creator=>person('person'), :observers=>person('person'))
+      Activity.for_stakeholder(person('person')).size.should == 1
     end
 
-    it 'should return activities from most recent to last' do
-      Task.create! defaults.merge(:creator=>person('creator'))
-      Activity.update_all ['created_at=?', Time.zone.now - 5.seconds]
-      Task.last.update_attributes! :owner=>person('owner')
-      activities = Activity.for_stakeholder(person('creator'))
-      activities.first.created_at.should > activities.last.created_at
+    it 'should not eager load dependencies' do
+      Activity.for_stakeholder(person('person')).proxy_options[:include].should be_empty
     end
 
   end