Skip to content

Commit

Permalink
Fix compats method for both gemmy and lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
etagwerker committed Sep 12, 2024
1 parent 5e3ddd0 commit ae28170
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
9 changes: 0 additions & 9 deletions app/models/concerns/has_compats.rb

This file was deleted.

6 changes: 4 additions & 2 deletions app/models/gemmy.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class Gemmy < ApplicationRecord
include HasCompats

FORBIDDEN_NAMES = %w(
new
edit
Expand All @@ -11,6 +9,10 @@ class Gemmy < ApplicationRecord

delegate :to_param, :to_s, to: :name

def compats
Compat.where(id: compat_ids)
end

def dependencies
dependencies_and_versions
.keys
Expand Down
6 changes: 4 additions & 2 deletions app/models/lockfile.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class Lockfile < ApplicationRecord
include HasCompats

has_many :dependencies, class_name: "LockfileDependency", dependent: :destroy
has_many :gemmies, through: :dependencies

Expand All @@ -11,6 +9,10 @@ class Lockfile < ApplicationRecord
delegate :to_param, to: :slug

scope :with_gemmies, ->(gemmies) { joins(:gemmies).where(gemmies: { id: gemmies }).distinct }

def compats
Compat.where(id: gemmies.flat_map(&:compat_ids))
end
end

# == Schema Information
Expand Down

0 comments on commit ae28170

Please sign in to comment.