docbrown/app/services/articles/feeds/timeframe.rb
Michael Kohl c7ba9d81db
Clean up feed-related code (#14707)
* Start cleaning up feed code

* Move published_articles_by_tag to service

* Add timeframe and latest feed services

* fixup! Move published_articles_by_tag to service

* Move constant to correct location

* Fix spec
2021-09-17 09:23:32 +07:00

15 lines
382 B
Ruby

module Articles
module Feeds
module Timeframe
def self.call(timeframe, tag: nil, number_of_articles: 50, page: 1)
articles = ::Articles::Feeds::Tag.call(tag)
articles
.where("published_at > ?", ::Timeframe.datetime(timeframe))
.order(score: :desc)
.page(page)
.per(number_of_articles)
end
end
end
end