docbrown/app/controllers/live_articles_controller.rb
Ben Halpern 8d6b0d868d
Modify and finalize live now for events (#346)
* Add MVP for live events

* Modify and finalize live now for events

* Add profile to front end of live article indicator

* Check for footer container before doing calculations on it
2018-05-23 14:46:46 -04:00

36 lines
1 KiB
Ruby

class LiveArticlesController < ApplicationController
before_action :set_cache_control_headers, only: [:index]
def index
@event = Event.find_by(live_now: true)
@article = Article.where(live_now: true).order("featured_number DESC").first
if @event
set_surrogate_key_header "live--event_#{@event.id}"
render json:
{
title: @event.title,
path: @event.location_url,
tag_list: [],
user: {
name: @event.host_name,
profile_pic: ProfileImage.new(@event).get(50),
},
}
elsif @article
set_surrogate_key_header "live--article_#{@article.id}"
render json:
{
title: @article.title,
path: @article.path,
tag_list: @article.tag_list,
user: {
name: @article.user.name,
profile_pic: ProfileImage.new(@article.user).get(50),
},
}
else
set_surrogate_key_header "live--nothing"
render json: {}
end
end
end