Skip to content

Commit

Permalink
exclude registration agencies from legacy API endpoints. datacite/lev…
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 12, 2019
1 parent 956330c commit bf16492
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion app/controllers/data_centers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ def index
elsif params[:ids].present?
response = Client.find_by_id(params[:ids], page: page, sort: sort)
else
response = Client.query(params[:query], year: params[:year], provider_id: params[:member_id], fields: params[:fields], page: page, sort: sort)
response = Client.query(params[:query],
exclude_registration_agencies: true,
year: params[:year],
provider_id: params[:member_id],
fields: params[:fields],
page: page,
sort: sort)
end

begin
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def index
elsif params[:ids].present?
response = Provider.find_by_id(params[:ids], page: page, sort: sort)
else
response = Provider.query(params[:query], year: params[:year], region: params[:region], organization_type: params[:organization_type], focus_area: params[:focus_area], fields: params[:fields], page: page, sort: sort)
response = Provider.query(params[:query], exclude_registration_agencies: true, year: params[:year], region: params[:region], organization_type: params[:organization_type], focus_area: params[:focus_area], fields: params[:fields], page: page, sort: sort)
end

begin
Expand Down
7 changes: 6 additions & 1 deletion app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,16 @@ def query(query, options={})
must << { term: { focus_area: options[:focus_area] }} if options[:focus_area].present?

must_not << { exists: { field: "deleted_at" }} unless options[:include_deleted]
must_not << { term: { role_name: "ROLE_ADMIN" }}
if options[:exclude_registration_agencies]
must_not << { terms: { role_name: ["ROLE_ADMIN", "ROLE_REGISTRATION_AGENCY"] }}
else
must_not << { term: { role_name: "ROLE_ADMIN" }}
end
elsif self.name == "Client"
must << { range: { created: { gte: "#{options[:year].split(",").min}||/y", lte: "#{options[:year].split(",").max}||/y", format: "yyyy" }}} if options[:year].present?
must << { terms: { "software.raw" => options[:software].split(",") }} if options[:software].present?
must_not << { exists: { field: "deleted_at" }} unless options[:include_deleted]
must_not << { terms: { provider_id: ["crossref"] }} if options[:exclude_registration_agencies]
elsif self.name == "Doi"
must << { terms: { aasm_state: options[:state].to_s.split(",") }} if options[:state].present?
must << { range: { registered: { gte: "#{options[:registered].split(",").min}||/y", lte: "#{options[:registered].split(",").max}||/y", format: "yyyy" }}} if options[:registered].present?
Expand Down

0 comments on commit bf16492

Please sign in to comment.