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

pulibrary / pdc_discovery / 79cc0f1f-db9d-4052-80b2-03da9188224f

08 Nov 2024 05:55PM UTC coverage: 96.43% (+0.2%) from 96.253%
79cc0f1f-db9d-4052-80b2-03da9188224f

Pull #714

circleci

jrgriffiniii
Addressing the failing tests for DSpace and DescribeIndexer
Pull Request #714: Improving test consistency for DSpace and DescribeIndexer

53 of 59 new or added lines in 6 files covered. (89.83%)

5 existing lines in 2 files now uncovered.

3593 of 3726 relevant lines covered (96.43%)

289.17 hits per line

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

83.33
/app/lib/dspace_indexer.rb
1
# frozen_string_literal: true
2

3
require 'faraday_middleware'
1✔
4
require 'traject'
1✔
5

6
##
7
# Index DSpace objects to solr
8
class DspaceIndexer
1✔
9
  REST_LIMIT = 100
1✔
10

11
  ##
12
  # @param [String] XML from DSpace rest interface
13
  def initialize(dspace_xml)
1✔
14
    @dspace_xml = dspace_xml
73✔
15
  end
16

17
  ##
18
  # Index XML as received from DSpace
19
  def index
1✔
20
    traject_indexer.process(@dspace_xml)
72✔
21
    traject_indexer.complete
71✔
22
  end
23

24
  def research_data_config_path
1✔
25
    pathname = ::Rails.root.join('config', 'traject', "dataspace_research_data_config.rb")
73✔
26
    pathname.to_s
73✔
27
  end
28

29
  ##
30
  # Load the traject indexing config for DataSpace research data objects
31
  def traject_indexer
1✔
32
    @traject_indexer ||= Traject::Indexer::NokogiriIndexer.new.tap do |i|
152✔
33
      i.load_config_file(research_data_config_path)
73✔
34
    end
35
  end
36

37
  ##
38
  # TODO: Pass in indexing options from the command line
39
  # Convenience method for kicking off indexing
40
  # @example DspaceIndexer.index(collection_handle: '88435/dsp015m60qr913')
41
  def self.index(_options)
1✔
42
    server = "#{Rails.configuration.pdc_discovery.dataspace_url}/rest"
1✔
43
    collection_id = '261'
1✔
44
    url = "#{server}/collections/#{collection_id}/items?limit=#{REST_LIMIT}&offset=0&expand=all"
1✔
45

46
    resp = Faraday.get(url, {}, { 'Accept': 'application/xml' })
1✔
47
    i = DspaceIndexer.new(resp.body)
1✔
48
    i.index
1✔
49
    i
1✔
50
  end
51

52
  def client
1✔
NEW
53
    @client ||= Blacklight.default_index.connection
×
54
  end
55

56
  def delete!(query:)
1✔
57
    # solr.delete_by_query 'price:1.00'
NEW
58
    client.delete_by_query(query)
×
NEW
59
    client.commit
×
NEW
60
    client.optimize
×
NEW
61
    client
×
62
  end
63
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