Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] remove support for predicate maps from search query #295

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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 .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
project: qa

- samvera/engine_cart_generate:
cache_key: v7-internal-test-app-{{ checksum "qa.gemspec" }}-{{ checksum "spec/test_app_templates/lib/generators/test_app_generator.rb" }}-{{ checksum "lib/generators/qa/install/install_generator.rb" }}-<< parameters.rails_version >>-<< parameters.ruby_version >>
cache_key: v11-internal-test-app-{{ checksum "qa.gemspec" }}-{{ checksum "spec/test_app_templates/lib/generators/test_app_generator.rb" }}-{{ checksum "lib/generators/qa/install/install_generator.rb" }}-<< parameters.rails_version >>-<< parameters.ruby_version >>

- samvera/bundle_for_gem:
ruby_version: << parameters.ruby_version >>
Expand Down
35 changes: 4 additions & 31 deletions lib/qa/authorities/linked_data/search_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,12 @@ def normalize_results
end

def map_results
predicate_map = preds_for_search
ldpath_map = ldpaths_for_search

raise Qa::InvalidConfiguration, "do not specify results using both predicates and ldpath in search configuration for linked data authority #{authority_name} (ldpath is preferred)" if predicate_map.present? && ldpath_map.present? # rubocop:disable Metrics/LineLength
raise Qa::InvalidConfiguration, "must specify label_ldpath or label_predicate in search configuration for linked data authority #{authority_name} (label_ldpath is preferred)" unless ldpath_map.key?(:label) || predicate_map.key?(:label) # rubocop:disable Metrics/LineLength

if predicate_map.present?
Qa.deprecation_warning(
in_msg: 'Qa::Authorities::LinkedData::SearchQuery',
msg: "defining results using predicates in search config is deprecated; update to define using ldpaths (authority: #{authority_name})"
)
unless ldpath_map.key?(:label)
raise Qa::InvalidConfiguration,
"must specify label_ldpath in search configuration for linked data authority #{authority_name}"
end

results_mapper_service.map_values(graph: filtered_graph, prefixes: prefixes, ldpath_map: ldpath_map,
predicate_map: predicate_map, sort_key: :sort,
results_mapper_service.map_values(graph: filtered_graph, prefixes: prefixes, ldpath_map: ldpath_map, sort_key: :sort,
preferred_language: language, context_map: context_map)
end

Expand Down Expand Up @@ -129,24 +120,6 @@ def sort_ldpath
@sort_ldpath ||= search_config.results_sort_ldpath
end

def preds_for_search
label_pred_uri = search_config.results_label_predicate(suppress_deprecation_warning: true)
return {} if label_pred_uri.blank?
preds = { label: label_pred_uri, uri: :subject_uri }
preds[:altlabel] = search_config.results_altlabel_predicate unless search_config.results_altlabel_predicate.nil?
preds[:id] = id_predicate.present? ? id_predicate : :subject_uri
preds[:sort] = sort_predicate.present? ? sort_predicate : preds[:label]
preds
end

def id_predicate
@id_predicate ||= search_config.results_id_predicate
end

def sort_predicate
@sort_predicate ||= search_config.results_sort_predicate
end

def convert_results_to_json(results)
json_results = []
results.each { |result| json_results << convert_result_to_json(result) }
Expand Down