Use new hanami db classes

This commit is contained in:
2024-08-05 18:44:20 +10:00
parent d7573d7038
commit 2ada50cbcd
52 changed files with 52 additions and 52 deletions

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class AutoTaggings < ROM::Relation[:sql] class AutoTaggings < Adamantium::DB::Relation
schema :auto_taggings, infer: true do schema :auto_taggings, infer: true do
associations do associations do
belongs_to :tag belongs_to :tag

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Highlights < ROM::Relation[:sql] class Highlights < Adamantium::DB::Relation
schema :highlights, infer: true do schema :highlights, infer: true do
associations do associations do
belongs_to :post belongs_to :post

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class LoginTokens < ROM::Relation[:sql] class LoginTokens < Adamantium::DB::Relation
schema :login_tokens, infer: true schema :login_tokens, infer: true
auto_struct(true) auto_struct(true)

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Movies < ROM::Relation[:sql] class Movies < Adamantium::DB::Relation
schema :movies, infer: true schema :movies, infer: true
auto_struct(true) auto_struct(true)

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Pages < ROM::Relation[:sql] class Pages < Adamantium::DB::Relation
schema :pages, infer: true schema :pages, infer: true
auto_struct(true) auto_struct(true)

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class PodcastScrobbles < ROM::Relation[:sql] class PodcastScrobbles < Adamantium::DB::Relation
schema :podcast_scrobbles, infer: true schema :podcast_scrobbles, infer: true
auto_struct(true) auto_struct(true)

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Podcasts < ROM::Relation[:sql] class Podcasts < Adamantium::DB::Relation
schema :podcasts, infer: true schema :podcasts, infer: true
auto_struct(true) auto_struct(true)

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class PostTags < ROM::Relation[:sql] class PostTags < Adamantium::DB::Relation
schema :post_tags, infer: true do schema :post_tags, infer: true do
associations do associations do
belongs_to :post belongs_to :post

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class PostTrips < ROM::Relation[:sql] class PostTrips < Adamantium::DB::Relation
schema :post_trips, infer: true do schema :post_trips, infer: true do
associations do associations do
belongs_to :post belongs_to :post

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Posts < ROM::Relation[:sql] class Posts < Adamantium::DB::Relation
schema :posts, infer: true do schema :posts, infer: true do
associations do associations do
has_many :post_tags has_many :post_tags

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Reactions < ROM::Relation[:sql] class Reactions < Adamantium::DB::Relation
schema :reactions, infer: true do schema :reactions, infer: true do
associations do associations do
belongs_to :post belongs_to :post

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Tags < ROM::Relation[:sql] class Tags < Adamantium::DB::Relation
schema :tags, infer: true do schema :tags, infer: true do
associations do associations do
has_many :post_tags has_many :post_tags

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class TopTracks < ROM::Relation[:sql] class TopTracks < Adamantium::DB::Relation
schema :top_tracks, infer: true schema :top_tracks, infer: true
auto_struct(true) auto_struct(true)

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Trips < ROM::Relation[:sql] class Trips < Adamantium::DB::Relation
schema :trips, infer: true do schema :trips, infer: true do
associations do associations do
has_many :post_trips has_many :post_trips

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Users < ROM::Relation[:sql] class Users < Adamantium::DB::Relation
schema :users, infer: true schema :users, infer: true
auto_struct(true) auto_struct(true)

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Webmentions < ROM::Relation[:sql] class Webmentions < Adamantium::DB::Relation
schema :webmentions, infer: true do schema :webmentions, infer: true do
associations do associations do
belongs_to :post belongs_to :post

View File

@@ -2,7 +2,7 @@
module Adamantium module Adamantium
module Relations module Relations
class Workouts < ROM::Relation[:sql] class Workouts < Adamantium::DB::Relation
schema :workouts, infer: true schema :workouts, infer: true
auto_struct(true) auto_struct(true)

View File

@@ -1,6 +1,6 @@
module Adamantium module Adamantium
module Repos module Repos
class PageRepo < Adamantium::Repo[:pages] class PageRepo < Adamantium::DB::Repo[:pages]
def fetch!(slug:) def fetch!(slug:)
pages pages
.published .published

View File

@@ -1,6 +1,6 @@
module Adamantium module Adamantium
module Repos module Repos
class PodcastScrobbleRepo < Adamantium::Repo[:podcast_scrobbles] class PodcastScrobbleRepo < Adamantium::DB::Repo[:podcast_scrobbles]
commands :create commands :create
def exists?(id:) def exists?(id:)

View File

@@ -2,7 +2,7 @@ require "time_math"
module Adamantium module Adamantium
module Repos module Repos
class PostRepo < Adamantium::Repo[:posts] class PostRepo < Adamantium::DB::Repo[:posts]
def recent(limit:) def recent(limit:)
date = Time.now date = Time.now

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class AutoTaggingRepo < Adamantium::Repo[:auto_taggings] class AutoTaggingRepo < Adamantium::DB::Repo[:auto_taggings]
commands :create commands :create
def find(id) def find(id)

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class BookRepo < Adamantium::Repo[:posts] class BookRepo < Adamantium::DB::Repo[:posts]
commands :create, update: :by_pk commands :create, update: :by_pk
def list_all def list_all

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class BookmarkRepo < Adamantium::Repo[:posts] class BookmarkRepo < Adamantium::DB::Repo[:posts]
def list def list
posts posts
.where(post_type: "bookmark") .where(post_type: "bookmark")

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class HighlightRepo < Adamantium::Repo[:highlights] class HighlightRepo < Adamantium::DB::Repo[:highlights]
commands :create, delete: :by_pk commands :create, delete: :by_pk
def list_all def list_all

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class LoginTokensRepo < Adamantium::Repo[:login_tokens] class LoginTokensRepo < Adamantium::DB::Repo[:login_tokens]
commands :create commands :create
def by_token(token:) def by_token(token:)

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class MovieRepo < Adamantium::Repo[:movies] class MovieRepo < Adamantium::DB::Repo[:movies]
commands :create commands :create
def by_title_and_year(title:, year:) def by_title_and_year(title:, year:)

View File

@@ -2,7 +2,7 @@ require "time_math"
module Admin module Admin
module Repos module Repos
class PageRepo < Adamantium::Repo[:pages] class PageRepo < Adamantium::DB::Repo[:pages]
commands :create, update: :by_pk commands :create, update: :by_pk
def list def list

View File

@@ -2,7 +2,7 @@ require "time_math"
module Admin module Admin
module Repos module Repos
class PostRepo < Adamantium::Repo[:posts] class PostRepo < Adamantium::DB::Repo[:posts]
commands update: :by_pk commands update: :by_pk
def tag_post(post_id:, tags:) def tag_post(post_id:, tags:)

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class PostTagRepo < Adamantium::Repo[:post_tags] class PostTagRepo < Adamantium::DB::Repo[:post_tags]
def merge_tags(target_id:, source_id:) def merge_tags(target_id:, source_id:)
post_tags.where(tag_id: source_id).update(tag_id: target_id) post_tags.where(tag_id: source_id).update(tag_id: target_id)
end end

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class PostTripRepo < Adamantium::Repo[:post_trips] class PostTripRepo < Adamantium::DB::Repo[:post_trips]
commands :create commands :create
def remove(trip_id:, post_id:) def remove(trip_id:, post_id:)

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class TagRepo < Adamantium::Repo[:tags] class TagRepo < Adamantium::DB::Repo[:tags]
def list def list
tags tags
.order(Sequel.function(:lower, :label)) .order(Sequel.function(:lower, :label))

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class TripRepo < Adamantium::Repo[:trips] class TripRepo < Adamantium::DB::Repo[:trips]
commands :create commands :create
def list def list

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class UserRepo < Adamantium::Repo[:users] class UserRepo < Adamantium::DB::Repo[:users]
commands :create commands :create
def exists(id) def exists(id)

View File

@@ -1,6 +1,6 @@
module Admin module Admin
module Repos module Repos
class WebmentionRepo < Adamantium::Repo[:webmentions] class WebmentionRepo < Adamantium::DB::Repo[:webmentions]
commands update: :by_pk commands update: :by_pk
def list_all_for_check def list_all_for_check

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class MovieRepo < Adamantium::Repo[:movies] class MovieRepo < Adamantium::DB::Repo[:movies]
def listing def listing
movies.order(Sequel.lit("year desc")).to_a movies.order(Sequel.lit("year desc")).to_a
end end

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class PageRepo < Adamantium::Repo[:pages] class PageRepo < Adamantium::DB::Repo[:pages]
def fetch!(slug:) def fetch!(slug:)
pages pages
.published .published

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class PodcastRepo < Adamantium::Repo[:podcasts] class PodcastRepo < Adamantium::DB::Repo[:podcasts]
def listing def listing
podcasts.order(:name).to_a podcasts.order(:name).to_a
end end

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class PodcastScrobbleRepo < Adamantium::Repo[:podcast_scrobbles] class PodcastScrobbleRepo < Adamantium::DB::Repo[:podcast_scrobbles]
def exists?(id:) def exists?(id:)
!!podcast_scrobbles !!podcast_scrobbles
.where(overcast_id: id) .where(overcast_id: id)

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class PostRepo < Adamantium::Repo[:posts] class PostRepo < Adamantium::DB::Repo[:posts]
Sequel.extension :pg_json Sequel.extension :pg_json
Sequel.extension :pg_json_ops Sequel.extension :pg_json_ops

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class PostTagRepo < Adamantium::Repo[:post_tags] class PostTagRepo < Adamantium::DB::Repo[:post_tags]
def posts_tagged(tag:) def posts_tagged(tag:)
tag_id = post_tags tag_id = post_tags
.tags .tags

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class ReactionRepo < Adamantium::Repo[:reactions] class ReactionRepo < Adamantium::DB::Repo[:reactions]
commands :create commands :create
def count(post_id:) def count(post_id:)

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class TagRepo < Adamantium::Repo[:tags] class TagRepo < Adamantium::DB::Repo[:tags]
def fetch!(slug) def fetch!(slug)
tags.where(slug: slug).one! tags.where(slug: slug).one!
end end

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class TopTrackRepo < Adamantium::Repo[:top_tracks] class TopTrackRepo < Adamantium::DB::Repo[:top_tracks]
def for_post(id:) def for_post(id:)
top_tracks top_tracks
.where(post_id: id) .where(post_id: id)

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class TripRepo < Adamantium::Repo[:trips] class TripRepo < Adamantium::DB::Repo[:trips]
def fetch!(id) def fetch!(id)
trips trips
.where(id: id) .where(id: id)

View File

@@ -1,6 +1,6 @@
module Main module Main
module Repos module Repos
class WorkoutRepo < Adamantium::Repo[:workouts] class WorkoutRepo < Adamantium::DB::Repo[:workouts]
def list def list
workouts.order(:published_at).to_a workouts.order(:published_at).to_a
end end

View File

@@ -1,6 +1,6 @@
module Micropub module Micropub
module Repos module Repos
class AutoTaggingRepo < Adamantium::Repo[:auto_taggings] class AutoTaggingRepo < Adamantium::DB::Repo[:auto_taggings]
def find(id) def find(id)
auto_taggings auto_taggings
.where(id: id) .where(id: id)

View File

@@ -1,6 +1,6 @@
module Micropub module Micropub
module Repos module Repos
class MovieRepo < Adamantium::Repo[:movies] class MovieRepo < Adamantium::DB::Repo[:movies]
commands :create commands :create
end end
end end

View File

@@ -1,6 +1,6 @@
module Micropub module Micropub
module Repos module Repos
class PodcastRepo < Adamantium::Repo[:podcasts] class PodcastRepo < Adamantium::DB::Repo[:podcasts]
commands :create commands :create
def listing def listing

View File

@@ -1,6 +1,6 @@
module Micropub module Micropub
module Repos module Repos
class PostRepo < Adamantium::Repo[:posts] class PostRepo < Adamantium::DB::Repo[:posts]
commands update: :by_pk commands update: :by_pk
def remove_tag(post_id:, tag:) def remove_tag(post_id:, tag:)

View File

@@ -1,6 +1,6 @@
module Micropub module Micropub
module Repos module Repos
class WebmentionsRepo < Adamantium::Repo[:webmentions] class WebmentionsRepo < Adamantium::DB::Repo[:webmentions]
commands :create commands :create
end end
end end

View File

@@ -1,6 +1,6 @@
module Micropub module Micropub
module Repos module Repos
class WorkoutRepo < Adamantium::Repo[:workouts] class WorkoutRepo < Adamantium::DB::Repo[:workouts]
commands :create, update: :by_pk commands :create, update: :by_pk
end end
end end

View File

@@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.describe "Webmention creation", :db, :requests do RSpec.describe "Webmention creation", :db, :requests do
let(:post_repo) { Adamantium::Repos::PostRepo.new } let(:post_repo) { Adamantium::DB::Repos::PostRepo.new }
let(:post_record) { Test::Factory[:post] } let(:post_record) { Test::Factory[:post] }
context "reply" do context "reply" do