Created
March 6, 2018 23:09
-
-
Save rosem/d91c387969262e935722c6dde46ba515 to your computer and use it in GitHub Desktop.
Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EventsController < APIController | |
# GET /events.xml | |
def index | |
@events = current_user.events.one_per_user.non_blocked(current_user.id) | |
if client_build_number < 171 | |
@events = @events.where("event_type = 'create'") | |
end | |
@events = @events.order("max(events.created_at) DESC").limit(25) | |
ActiveRecord::Associations::Preloader.new(@events,[{:eventable => :user}, :whom]).run | |
respond_with @events, :api_template => :index | |
end | |
prepend_after_filter :set_viewed_events | |
private | |
def set_viewed_events | |
current_user.events.update_all('viewed = true') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment