Skip to content

Commit

Permalink
Add support to bulk_checker to not return matches
Browse files Browse the repository at this point in the history
  • Loading branch information
JPrevost committed Oct 23, 2024
1 parent e3a6b7b commit bde39e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions app/models/detector/bulk_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ module BulkChecker
# - the Class including this module implements a `detections` method (either via `attr_reader` or as a method)
# that is only populated for Terms in which it has made a detection
# - the initialize method accepts a `phrase` as a string
def check_all_matches
# @param output [boolean] optional. Defaults to false as that is the more likely scenario useful in development as
# the logger output is often what is desired.
def check_all_matches(output = false)
count = 0
matches = []
Term.find_each do |t|
Expand All @@ -27,7 +29,7 @@ def check_all_matches
Rails.logger.ap "Total Terms: #{Term.count}"
Rails.logger.ap "Total Matches: #{count}"

matches
matches if output
end
end
end
6 changes: 3 additions & 3 deletions test/models/detector/bulk_checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Detector
class CitationTest < ActiveSupport::TestCase
test 'citation_bulk_checker' do
bulk = Detector::Citation.check_all_matches
bulk = Detector::Citation.check_all_matches(output = true)

assert_equal(1, bulk.count)
end
Expand All @@ -15,13 +15,13 @@ class CitationTest < ActiveSupport::TestCase
end

test 'lcsh_bulk_checker' do
bulk = Detector::Lcsh.check_all_matches
bulk = Detector::Lcsh.check_all_matches(output = true)

assert_equal(1, bulk.count)
end

test 'standard_identifier_bulk_checker' do
bulk = Detector::StandardIdentifiers.check_all_matches
bulk = Detector::StandardIdentifiers.check_all_matches(output = true)

assert_equal(5, bulk.count)
end
Expand Down

0 comments on commit bde39e8

Please sign in to comment.