Skip to content

Commit

Permalink
Implement scopes for judgings
Browse files Browse the repository at this point in the history
  • Loading branch information
smolnar committed Jun 16, 2024
1 parent 99ac3ff commit 15cc3c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/hearing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class Hearing < OpenCourts::ApplicationRecord
belongs_to :original_court, class_name: :Court, optional: true

has_many :judgings
has_many :exact_judgings, -> { exact }, class_name: :Judging
has_many :inexact_judgings, -> { inexact }, class_name: :Judging
has_many :judges, through: :judgings

belongs_to :type, class_name: 'Hearing::Type', foreign_key: :hearing_type_id
Expand Down
3 changes: 3 additions & 0 deletions app/models/judging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
class Judging < OpenCourts::ApplicationRecord
belongs_to :judge, optional: true
belongs_to :hearing

scope :exact, -> { where(judge_name_similarity: 1.0) }
scope :inexact, -> { where.not(judge_name_similarity: 1.0) }
end

0 comments on commit 15cc3c5

Please sign in to comment.