Bring app in line with Hanami 2.1.0 base
This commit is contained in:
15
app/relations/auto_taggings.rb
Normal file
15
app/relations/auto_taggings.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class AutoTaggings < ROM::Relation[:sql]
|
||||
schema :auto_taggings, infer: true do
|
||||
associations do
|
||||
belongs_to :tag
|
||||
end
|
||||
end
|
||||
|
||||
auto_struct(true)
|
||||
end
|
||||
end
|
||||
end
|
11
app/relations/movies.rb
Normal file
11
app/relations/movies.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class Movies < ROM::Relation[:sql]
|
||||
schema :movies, infer: true
|
||||
|
||||
auto_struct(true)
|
||||
end
|
||||
end
|
||||
end
|
11
app/relations/podcasts.rb
Normal file
11
app/relations/podcasts.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class Podcasts < ROM::Relation[:sql]
|
||||
schema :podcasts, infer: true
|
||||
|
||||
auto_struct(true)
|
||||
end
|
||||
end
|
||||
end
|
16
app/relations/post_tags.rb
Normal file
16
app/relations/post_tags.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class PostTags < ROM::Relation[:sql]
|
||||
schema :post_tags, infer: true do
|
||||
associations do
|
||||
belongs_to :post
|
||||
belongs_to :tag
|
||||
end
|
||||
end
|
||||
|
||||
auto_struct(true)
|
||||
end
|
||||
end
|
||||
end
|
16
app/relations/post_trips.rb
Normal file
16
app/relations/post_trips.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
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
|
40
app/relations/posts.rb
Normal file
40
app/relations/posts.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class Posts < ROM::Relation[:sql]
|
||||
schema :posts, infer: true do
|
||||
associations do
|
||||
has_many :post_tags
|
||||
has_many :tags, through: :post_tags
|
||||
|
||||
has_many :post_trips
|
||||
has_many :trips, through: :post_trips
|
||||
|
||||
has_many :webmentions
|
||||
end
|
||||
end
|
||||
|
||||
auto_struct(true)
|
||||
|
||||
def published
|
||||
where(self[:published_at] <= Time.now)
|
||||
end
|
||||
|
||||
def weekly
|
||||
ref = post_tags.where(tag_id: "70").select(:post_id).dataset
|
||||
where(id: ref)
|
||||
end
|
||||
|
||||
def non_weekly
|
||||
ref = post_tags.where(tag_id: "70").select(:post_id).dataset
|
||||
exclude(id: ref)
|
||||
end
|
||||
|
||||
def published_between(start_date, end_date)
|
||||
where(self[:published_at] >= start_date)
|
||||
.where(self[:published_at] <= end_date)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
app/relations/tags.rb
Normal file
16
app/relations/tags.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class Tags < ROM::Relation[:sql]
|
||||
schema :tags, infer: true do
|
||||
associations do
|
||||
has_many :post_tags
|
||||
has_many :posts, through: :post_tags
|
||||
end
|
||||
end
|
||||
|
||||
auto_struct(true)
|
||||
end
|
||||
end
|
||||
end
|
11
app/relations/top_tracks.rb
Normal file
11
app/relations/top_tracks.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class TopTracks < ROM::Relation[:sql]
|
||||
schema :top_tracks, infer: true
|
||||
|
||||
auto_struct(true)
|
||||
end
|
||||
end
|
||||
end
|
20
app/relations/trips.rb
Normal file
20
app/relations/trips.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
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)
|
||||
|
||||
def published
|
||||
where(self[:start_date] <= Time.now)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
app/relations/webmentions.rb
Normal file
19
app/relations/webmentions.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class Webmentions < ROM::Relation[:sql]
|
||||
schema :webmentions, infer: true do
|
||||
associations do
|
||||
belongs_to :post
|
||||
end
|
||||
end
|
||||
|
||||
auto_struct(true)
|
||||
|
||||
def published
|
||||
where(self[:published_at] <= Time.now)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
11
app/relations/workouts.rb
Normal file
11
app/relations/workouts.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Adamantium
|
||||
module Relations
|
||||
class Workouts < ROM::Relation[:sql]
|
||||
schema :workouts, infer: true
|
||||
|
||||
auto_struct(true)
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user