aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/track_controller.rb
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-10-09 04:06:38 +0100
committerFrancis Irving <francis@mysociety.org>2010-10-09 04:06:38 +0100
commit70d8b2d24c68ec57a8e5a0fcc618f690a989e920 (patch)
tree173472502ab8f8b454b8bdab9ff7955d52379398 /app/controllers/track_controller.rb
parent3f7e2f21d7b291dda6dc180ad3ca4f6db3e252eb (diff)
.json form for RSS feeds
Diffstat (limited to 'app/controllers/track_controller.rb')
-rw-r--r--app/controllers/track_controller.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index 863477c0a..ff17eb25f 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -25,7 +25,7 @@ class TrackController < ApplicationController
def track_list
@view = params[:view]
- if @view.nil?
+ if @view == 'recent' || @view.nil? # the blank one for backwards compatibility
@track_thing = TrackThing.create_track_for_all_new_requests
elsif @view == 'successful'
@track_thing = TrackThing.create_track_for_all_successful_requests
@@ -118,7 +118,29 @@ class TrackController < ApplicationController
@xapian_object = perform_search([InfoRequestEvent], @track_thing.track_query, @track_thing.params[:feed_sortby], nil, 25, 1)
respond_to do |format|
format.atom { render :template => 'track/atom_feed' }
- end
+ format.json {
+ render :json =>
+ @xapian_object.results.map { |r| {
+ # XXX this code is partly duplicated with the request controller
+ :id => r[:model].id,
+ :event_type => r[:model].event_type,
+ :info_request => r[:model].info_request.url_title,
+ :public_body => r[:model].info_request.public_body.url_name,
+ :user => r[:model].info_request.user.url_name,
+ # params_yaml has possibly sensitive data in it, don't include it
+ :created_at => r[:model].created_at,
+ :described_state => r[:model].described_state,
+ :calculated_state => r[:model].calculated_state,
+ :last_described_at => r[:model].last_described_at,
+ :incoming_message_id => r[:model].incoming_message_id,
+ :outgoing_message_id => r[:model].outgoing_message_id,
+ :comment_id => r[:model].comment_id,
+ # XXX would be nice to add links here, but alas the
+ # code to make them is in views only. See views/request/details.rhtml
+ }
+ }
+ }
+ end
end
# Change or delete a track