docbrown/app/controllers/buffered_articles_controller.rb
Ben Halpern e4c120db5d
Replace dev.to with APP_DOMAIN config in a few places (#1406)
* Replace dev.to with APP_DOMAIN config in a few places

* Modify some tests
2018-12-26 18:13:05 -05:00

19 lines
581 B
Ruby

class BufferedArticlesController < ApplicationController
# No authorization required for entirely public controller
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://#{ApplicationConfig["APP_DOMAIN"]}#{a.path}" }
else
Article.all.map { |a| "https://#{ApplicationConfig["APP_DOMAIN"]}#{a.path}" }
end
end
end