Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/enhancer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class Enhancer
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect formatting, autoformat by running qlty fmt. [rubocop:fmt]

attr_accessor :enhanced_query

QUERY_PARAMS = %i[q citation contentType contributors fundingInformation identifiers locations subjects title queryMode].freeze
QUERY_PARAMS = %i[q citation contentType contributors fundingInformation identifiers locations subjects title queryMode queryTuning].freeze
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [141/120] [rubocop:Layout/LineLength]

FILTER_PARAMS = %i[accessToFilesFilter contentTypeFilter contributorsFilter formatFilter languagesFilter
literaryFormFilter placesFilter sourceFilter subjectsFilter].freeze
GEO_PARAMS = %i[geoboxMinLongitude geoboxMinLatitude geoboxMaxLongitude geoboxMaxLatitude geodistanceLatitude
Expand Down
11 changes: 11 additions & 0 deletions app/models/query_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ def evaluate_query_mode(enhanced_query)

# Validate against allow list
mode = 'keyword' unless VALID_QUERY_MODES.include?(mode)

# Override mode based on numeric tuning parameter if specific values present
if enhanced_query[:queryTuning]
Rails.logger.debug 'Query Tuning parameter present - checking for override'
Rails.logger.debug "queryTuning is #{enhanced_query[:queryTuning]}"
mode = 'keyword' if enhanced_query[:queryTuning].to_f == 0.0
mode = 'hybrid' if (enhanced_query[:queryTuning].to_f - 0.5).abs < Float::EPSILON
mode = 'semantic' if (enhanced_query[:queryTuning].to_f - 1.0).abs < Float::EPSILON
Rails.logger.debug "Query mode set to #{mode}"
end

@query['queryMode'] = mode
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found 3 issues:

1. Function with high complexity (count = 9): evaluate_query_mode [qlty:function-complexity]


2. Assignment Branch Condition size for evaluate_query_mode is too high. [<7, 25, 9> 27.48/17] [rubocop:Metrics/AbcSize]


3. Method has too many lines. [12/10] [rubocop:Metrics/MethodLength]

end
end