• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_discovery / cac84128-edcc-4a99-843f-9707d11f7ec9

04 Mar 2025 06:25PM UTC coverage: 96.536% (-0.4%) from 96.91%
cac84128-edcc-4a99-843f-9707d11f7ec9

push

circleci

web-flow
remove additinal dspace refrences (#761)

And dspace fixtures

2982 of 3089 relevant lines covered (96.54%)

106.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.31
/app/lib/indexing/import_helper.rb
1
# frozen_string_literal: true
2
module Indexing
1✔
3
  class ImportHelper
1✔
4
    def self.uri_with_prefix(prefix, value)
1✔
5
      return nil if value.blank?
3,196✔
6
      "#{prefix}/#{value}"
3,196✔
7
    end
8

9
    def self.doi_uri(value)
1✔
10
      uri_with_prefix("https://doi.org", value)
1,598✔
11
    end
12

13
    def self.ark_uri(value)
1✔
14
      uri_with_prefix("http://arks.princeton.edu", value)
1,598✔
15
    end
16

17
    # Returns true if a record already exists in Solr for the given URIs
18
    # and that record was imported from PDC Describe.
19
    def self.pdc_describe_match?(solr_url, uris)
1✔
20
      ark_uri = uris.find { |uri| uri.text.start_with?("http://arks.princeton.edu/ark:/") }&.text
×
21
      return true if pdc_describe_match_by_uri?(solr_url, ark_uri)
×
22

23
      doi_uri = uris.find { |uri| uri.text.start_with?("https://doi.org/10.34770/") }&.text
×
24
      return true if pdc_describe_match_by_uri?(solr_url, doi_uri)
×
25

26
      false
×
27
    end
28

29
    # Returns true if a record already exists in Solr for the given URI
30
    # and that record was imported from PDC Describe.
31
    def self.pdc_describe_match_by_uri?(solr_url, uri)
1✔
32
      return false if uri.nil?
1✔
33
      solr_query = File.join(solr_url, "select?q=data_source_ssi:pdc_describe+AND+uri_ssim:\"#{uri}\"")
1✔
34
      response = HTTParty.get(solr_query)
1✔
35
      response.parsed_response["response"]["numFound"] != 0
×
36
    rescue Errno::ECONNREFUSED => connection_error
37
      error_message = "HTTP GET request failed for #{solr_query}: #{connection_error}"
1✔
38
      Rails.logger.error(error_message)
1✔
39
      Honeybadger.notify(error_message)
1✔
40
      false
1✔
41
    end
42

43
    # Returns the URI to access the folder in Globus where the data is stored for the given file
44
    def self.globus_folder_uri_from_file(filename)
1✔
45
      origin_id = Rails.configuration.pdc_discovery.globus_collection_uuid
1,534✔
46
      file_path = File.dirname(filename)
1,534✔
47
      origin_path = CGI.escape("/#{file_path}/")
1,534✔
48
      "https://app.globus.org/file-manager?origin_id=#{origin_id}&origin_path=#{origin_path}"
1,534✔
49
    end
50
  end
51
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc