Add posts from archive to weekly posts

This commit is contained in:
2023-03-06 16:05:54 +11:00
parent 142af0b42b
commit 72cc4cc3ee
4 changed files with 49 additions and 12 deletions

View File

@@ -124,6 +124,25 @@ module Adamantium
.one
end
def from_the_archives(start_date:, end_date:)
# SELECT * FROM posts
# WHERE EXTRACT(month FROM "published_at") >= 2
# WHERE EXTRACT(month FROM "published_at") <= 2+
# AND EXTRACT(day FROM "published_at") > 20
# AND EXTRACT(day FROM "published_at") < 27
# AND post_type = 'post';
posts
.where(post_type: "post")
.published
.where { Sequel.extract(:year, :published_at) < start_date.year }
.where { Sequel.extract(:month, :published_at) >= start_date.month }
.where { Sequel.extract(:month, :published_at) <= end_date.month }
.where { Sequel.extract(:day, :published_at) >= start_date.day }
.where { Sequel.extract(:day, :published_at) <= end_date.day }
.to_a
end
def for_rss
posts
.where(post_type: "post", location: nil)