Add trips

This commit is contained in:
2023-05-09 21:51:44 +10:00
parent ebdf051b82
commit 7988ffc76d
37 changed files with 651 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
# frozen_string_literal: true
module Adamantium
module Persistence
module Relations
class PostTrips < ROM::Relation[:sql]
schema :post_trips, infer: true do
associations do
belongs_to :post
belongs_to :trip
end
end
auto_struct(true)
end
end
end
end

View File

@@ -8,6 +8,9 @@ module Adamantium
associations do
has_many :post_tags
has_many :tags, through: :post_tags
has_many :post_trips
has_many :trips, through: :post_trips
end
end
@@ -16,6 +19,11 @@ module Adamantium
def published
where(self[:published_at] <= Time.now)
end
def published_between(start_date, end_date)
where(self[:published_at] >= start_date)
.where(self[:published_at] <= end_date)
end
end
end
end

View File

@@ -0,0 +1,18 @@
# frozen_string_literal: true
module Adamantium
module Persistence
module Relations
class Trips < ROM::Relation[:sql]
schema :trips, infer: true do
associations do
has_many :post_trips
has_many :posts, through: :post_trips
end
end
auto_struct(true)
end
end
end
end