Author: assaf
Date: Sun Jun 15 19:16:44 2008
New Revision: 668036
URL: http://svn.apache.org/viewvc?rev=668036&view=rev
Log:
Feeds now link back to source page.
Fixed bug in activity and completed sparklines.
Activities feed limited to 50 entries, page to 2 days, graph to 1 month.
Modified:
ode/sandbox/singleshot/app/controllers/activity_controller.rb
ode/sandbox/singleshot/app/controllers/tasks_controller.rb
ode/sandbox/singleshot/app/models/activity.rb
ode/sandbox/singleshot/app/views/activity/index.atom.builder
ode/sandbox/singleshot/app/views/activity/index.html.erb
ode/sandbox/singleshot/app/views/tasks/completed.html.erb
ode/sandbox/singleshot/app/views/tasks/index.atom.builder
Modified: ode/sandbox/singleshot/app/controllers/activity_controller.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/activity_controller.rb?rev=668036&r1=668035&r2=668036&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/activity_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/activity_controller.rb Sun Jun 15
19:16:44 2008
@@ -5,16 +5,17 @@
def index
@title = 'Activities'
@subtitle = 'Track activity in tasks you participate in or observe.'
- @alternate = { Mime::ATOM=>formatted_activity_url(:format=>:atom,
:access_key=>authenticated.access_key),
+ @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)
- day = Date.new(params[:year].to_i, params[:month].to_i, params[:day].to_i)
rescue nil if params[:year]
- dates = day ? day..day + 1.day : Date.current - 3.day..Date.current + 1.day
- @activities = @activities.for_dates(dates)
respond_to do |want|
- want.html
- want.atom
- want.ics
+ want.html do
+ @graph =
Activity.for_stakeholder(authenticated).for_dates(Date.current - 1.month)
+ yesterday = Date.yesterday
+ @activities = @graph.select { |activity| activity.created_at >=
yesterday }
+ end
+ want.atom { @activities =
Activity.for_stakeholder(authenticated).scoped(:limit=>50) }
+ want.ics { @activities =
Activity.for_stakeholder(authenticated).scoped(:limit=>50) }
end
end
@@ -23,10 +24,11 @@
@activities = @task.activities
@title = "Activities - [EMAIL PROTECTED]"
@subtitle = "Track all activities in the task [EMAIL PROTECTED]"
- @alternate = { Mime::ATOM=>formatted_task_activity_url(@task,
:format=>:atom, :access_key=>authenticated.access_key),
+ @alternate = { Mime::HTML=>task_activity_url(@task),
+ Mime::ATOM=>formatted_task_activity_url(@task,
:format=>:atom, :access_key=>authenticated.access_key),
Mime::ICS=>formatted_task_activity_url(@task,
:format=>:ics, :access_key=>authenticated.access_key) }
respond_to do |want|
- want.html { render :action=>'index' }
+ want.html { @graph = @activities ; render :action=>'index' }
want.atom { render :action=>'index' }
want.ics { render :action=>'index' }
end
Modified: ode/sandbox/singleshot/app/controllers/tasks_controller.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/controllers/tasks_controller.rb?rev=668036&r1=668035&r2=668036&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/controllers/tasks_controller.rb (original)
+++ ode/sandbox/singleshot/app/controllers/tasks_controller.rb Sun Jun 15
19:16:44 2008
@@ -8,7 +8,8 @@
def index
@title, @subtitle = 'Tasks', 'Tasks you are performing or can claim for
your own.'
- @alternate = { Mime::ATOM=>formatted_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
+ @alternate = { Mime::HTML=>tasks_url,
+ Mime::ATOM=>formatted_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
Mime::ICS=>formatted_tasks_url(:format=>:ics,
:access_key=>authenticated.access_key) }
@tasks =
Task.pending.for_stakeholder(authenticated).with_stakeholders.rank_for(authenticated)
respond_to do |wants|
@@ -22,12 +23,13 @@
def completed
@title, @subtitle = 'Completed', 'Completed tasks'
- @alternate = { Mime::ATOM=>formatted_completed_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
+ @alternate = { Mime::HTML=>completed_tasks_url,
+ Mime::ATOM=>formatted_completed_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
Mime::ICS=>formatted_completed_tasks_url(:format=>:ics,
:access_key=>authenticated.access_key) }
@tasks = Task.completed.for_stakeholder(authenticated).with_stakeholders
respond_to do |wants|
wants.html do
- @graph = Task.connection.select_values("SELECT tasks.updated_at FROM
tasks JOIN stakeholders ON stakeholders.task_id = tasks.id WHERE
person_id=#{authenticated.id} AND role='owner' AND status='completed' AND
tasks.updated_at >= '#{Date.current - 1.month}'").group_by { |date|
date.to_date }.map { |date, entries| entries.size }
+ @graph = Task.connection.select_values("SELECT tasks.updated_at FROM
tasks, stakeholders WHERE stakeholders.task_id = tasks.id AND
person_id=#{authenticated.id} AND role='owner' AND status='completed' AND
tasks.updated_at >= '#{Date.current - 1.month}'")
end
# TODO: wants.xml
# TODO: wants.json
@@ -38,7 +40,8 @@
def following
@title, @subtitle = 'Following', 'Tasks you created, observing or
managing.'
- @alternate = { Mime::ATOM=>formatted_following_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
+ @alternate = { Mime::HTML=>following_tasks_url,
+ Mime::ATOM=>formatted_following_tasks_url(:format=>:atom,
:access_key=>authenticated.access_key),
Mime::ICS=>formatted_following_tasks_url(:format=>:ics,
:access_key=>authenticated.access_key) }
@tasks = Task.following.for_stakeholder(authenticated).with_stakeholders
respond_to do |wants|
@@ -52,7 +55,8 @@
def show
@title = @task.title
- @alternate = { Mime::ICS=>formatted_task_url(@task, :format=>:ics,
:access_key=>authenticated.access_key),
+ @alternate = { Mime::HTML=>task_url(@task),
+ Mime::ICS=>formatted_task_url(@task, :format=>:ics,
:access_key=>authenticated.access_key),
Mime::ATOM=>formatted_task_activity_url(@task,
:format=>:atom, :access_key=>authenticated.access_key) }
respond_to do |wants|
wants.html { render :layout=>'head' }
Modified: ode/sandbox/singleshot/app/models/activity.rb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/models/activity.rb?rev=668036&r1=668035&r2=668036&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/models/activity.rb (original)
+++ ode/sandbox/singleshot/app/models/activity.rb Sun Jun 15 19:16:44 2008
@@ -25,8 +25,13 @@
{ :joins=>'JOIN stakeholders AS involved ON involved.task_id=tasks.id',
:conditions=>["involved.person_id=? AND involved.role != 'excluded'",
person.id],
:include=>[:task, :person], :order=>'activities.created_at DESC' } }
- named_scope :for_dates, lambda { |dates|
- range = dates.min.to_time.beginning_of_day..dates.max.to_time.end_of_day
+ named_scope :for_dates, lambda { |range|
+ case range
+ when Date
+ range = range.to_time..Time.current.end_of_day
+ when Range
+ range = range.min.to_time.beginning_of_day..range.max.to_time.end_of_day
+ end
{ :conditions=>{ :created_at=>range } } }
end
Modified: ode/sandbox/singleshot/app/views/activity/index.atom.builder
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/activity/index.atom.builder?rev=668036&r1=668035&r2=668036&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/activity/index.atom.builder (original)
+++ ode/sandbox/singleshot/app/views/activity/index.atom.builder Sun Jun 15
19:16:44 2008
@@ -1,4 +1,4 @@
-atom_feed :root_url=>activity_url do |feed|
+atom_feed :root_url=>@alternate[Mime::HTML] do |feed|
feed.title @title
feed.subtitle @subtitle
feed.updated @activities.first.created_at unless @activities.empty?
@@ -9,7 +9,7 @@
entry.title activity_to_text(activity)
entry.content :type=>'html' do |content|
content.text! "<p>#{activity_to_html(activity)}</p>"
- content.text! truncate(strip_tags(task.description), 250)
+ content.text! truncate(strip_tags(task.description), 250)
end
entry.author do |author|
author.name activity.person.fullname if activity.person
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=668036&r1=668035&r2=668036&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/activity/index.html.erb (original)
+++ ode/sandbox/singleshot/app/views/activity/index.html.erb Sun Jun 15
19:16:44 2008
@@ -1,8 +1,9 @@
-<% by_date = group_by_dates(@activities, :created_at) %>
-<div class='right'><%= sparkline_tag @activities.group_by { |activity|
activity.created_at.to_date }.map { |time, list| list.size },
- :title=>'Level of activity for each day'
unless @activities.empty? %></div>
+<% graph = @graph.group_by { |activity| activity.created_at.to_date }
+ range = graph.last.first..Date.current %>
+<div class='right'><%= sparkline_tag range.map { |date| graph[date] ?
graph[date].size : 0 },
+ :title=>'Level of activity for each day'
unless graph.empty? %></div>
<ol class='dates hfeed'>
- <% for date, activities in by_date %>
+ <% for date, activities in group_by_dates(@activities, :created_at) %>
<li class='date'>
<h2><%= date.humanize %></h2>
<%= render :partial=>'activities', :locals=>{ :activities=>activities,
:today=>nil } %>
Modified: ode/sandbox/singleshot/app/views/tasks/completed.html.erb
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/completed.html.erb?rev=668036&r1=668035&r2=668036&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/completed.html.erb (original)
+++ ode/sandbox/singleshot/app/views/tasks/completed.html.erb Sun Jun 15
19:16:44 2008
@@ -1,7 +1,9 @@
-<% by_date = group_by_dates(@tasks, :updated_at) %>
-<div class='right'><%= sparkline_tag @graph, :title=>'Tasks completed each day
in the last month' unless @graph.empty? %></div>
+<% graph = @graph.group_by { |updated| updated.to_date }
+ range = graph.last.first..Date.current %>
+<div class='right'><%= sparkline_tag range.map { |date| graph[date] ?
graph[date].size : 0 },
+ :title=>'Tasks completed each day in the
last month' unless graph.empty? %></div>
<ol class='dates hfeed'>
- <% for date, tasks in by_date %>
+ <% for date, tasks in group_by_dates(@tasks, :updated_at) %>
<li class='date'>
<h2><%= date.humanize %></h2>
<ol class='tasks'>
Modified: ode/sandbox/singleshot/app/views/tasks/index.atom.builder
URL:
http://svn.apache.org/viewvc/ode/sandbox/singleshot/app/views/tasks/index.atom.builder?rev=668036&r1=668035&r2=668036&view=diff
==============================================================================
--- ode/sandbox/singleshot/app/views/tasks/index.atom.builder (original)
+++ ode/sandbox/singleshot/app/views/tasks/index.atom.builder Sun Jun 15
19:16:44 2008
@@ -1,4 +1,4 @@
-atom_feed :root_url=>tasks_url do |feed|
+atom_feed :root_url=>@alternate[Mime::HTML] do |feed|
feed.title 'Singleshot: Tasks'
feed.updated @tasks.map(&:updated_at).max