docbrown/app/controllers/buffered_articles_controller.rb
2018-05-22 15:40:42 -04:00

18 lines
465 B
Ruby

class BufferedArticlesController < ApplicationController
def index
@article_urls = buffered_article_urls
render json: {
urls: @article_urls,
}.to_json
end
def buffered_article_urls
if Rails.env.production?
Article.
where("last_buffered > ? OR published_at > ?", 24.hours.ago, 20.minutes.ago).
map { |a| "https://dev.to#{a.path}" }
else
Article.all.map { |a| "https://dev.to#{a.path}" }
end
end
end