blacklight-spotlight 3.0.0.rc3 → 3.0.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spotlight/admin/reindex_monitor.js +1 -0
  3. data/app/assets/stylesheets/spotlight/browse_group_categories_block.scss +23 -0
  4. data/app/controllers/spotlight/catalog_controller.rb +4 -1
  5. data/app/controllers/spotlight/dashboards_controller.rb +1 -1
  6. data/app/controllers/spotlight/exhibits_controller.rb +1 -1
  7. data/app/helpers/spotlight/application_helper.rb +19 -0
  8. data/app/helpers/spotlight/pages_helper.rb +1 -1
  9. data/app/jobs/concerns/spotlight/job_tracking.rb +47 -0
  10. data/app/jobs/concerns/spotlight/limit_concurrency.rb +33 -0
  11. data/app/jobs/spotlight/add_uploads_from_csv.rb +6 -3
  12. data/app/jobs/spotlight/application_job.rb +8 -0
  13. data/app/jobs/spotlight/cleanup_job_trackers_job.rb +13 -0
  14. data/app/jobs/spotlight/default_thumbnail_job.rb +1 -3
  15. data/app/jobs/spotlight/reindex_exhibit_job.rb +36 -0
  16. data/app/jobs/spotlight/reindex_job.rb +49 -41
  17. data/app/jobs/spotlight/rename_sidecar_field_job.rb +2 -2
  18. data/app/jobs/spotlight/update_job_trackers_job.rb +20 -0
  19. data/app/models/concerns/spotlight/user.rb +2 -1
  20. data/app/models/spotlight/event.rb +13 -0
  21. data/app/models/spotlight/exhibit.rb +4 -14
  22. data/app/models/spotlight/job_tracker.rb +105 -0
  23. data/app/models/spotlight/reindex_progress.rb +44 -27
  24. data/app/models/spotlight/resource.rb +24 -58
  25. data/app/models/spotlight/resources/iiif_harvester.rb +10 -1
  26. data/app/models/spotlight/resources/iiif_manifest.rb +3 -1
  27. data/app/models/spotlight/resources/iiif_service.rb +1 -1
  28. data/app/models/spotlight/resources/json_upload.rb +12 -0
  29. data/app/models/spotlight/resources/upload.rb +25 -2
  30. data/app/models/spotlight/solr_document_sidecar.rb +2 -1
  31. data/app/services/spotlight/etl.rb +7 -0
  32. data/app/services/spotlight/etl/context.rb +52 -0
  33. data/app/services/spotlight/etl/executor.rb +194 -0
  34. data/app/services/spotlight/etl/loaders.rb +12 -0
  35. data/app/services/spotlight/etl/pipeline.rb +81 -0
  36. data/app/services/spotlight/etl/solr_loader.rb +96 -0
  37. data/app/services/spotlight/etl/sources.rb +25 -0
  38. data/app/services/spotlight/etl/step.rb +82 -0
  39. data/app/services/spotlight/etl/transforms.rb +64 -0
  40. data/app/services/spotlight/validity_checker.rb +5 -5
  41. data/app/views/spotlight/dashboards/_reindexing_activity.html.erb +6 -6
  42. data/app/views/spotlight/shared/_locale_picker.html.erb +1 -1
  43. data/app/views/spotlight/sir_trevor/blocks/_browse_group_categories_block.html.erb +4 -3
  44. data/config/locales/spotlight.ar.yml +11 -1
  45. data/config/locales/spotlight.en.yml +3 -2
  46. data/db/migrate/20210122082032_create_job_trackers.rb +22 -0
  47. data/db/migrate/20210126123041_create_events.rb +15 -0
  48. data/lib/generators/spotlight/scaffold_resource_generator.rb +5 -13
  49. data/lib/spotlight/engine.rb +8 -1
  50. data/lib/spotlight/version.rb +1 -1
  51. data/spec/controllers/spotlight/catalog_controller_spec.rb +3 -1
  52. data/spec/examples.txt +1448 -1437
  53. data/spec/factories/job_trackers.rb +9 -0
  54. data/spec/features/add_items_spec.rb +9 -4
  55. data/spec/features/javascript/reindex_monitor_spec.rb +1 -1
  56. data/spec/features/site_users_management_spec.rb +4 -4
  57. data/spec/helpers/spotlight/pages_helper_spec.rb +8 -0
  58. data/spec/jobs/spotlight/reindex_exhibit_job_spec.rb +43 -0
  59. data/spec/jobs/spotlight/reindex_job_spec.rb +30 -59
  60. data/spec/models/spotlight/exhibit_spec.rb +3 -57
  61. data/spec/models/spotlight/reindex_progress_spec.rb +89 -87
  62. data/spec/models/spotlight/resource_spec.rb +69 -90
  63. data/spec/models/spotlight/resources/iiif_harvester_spec.rb +9 -10
  64. data/spec/models/spotlight/solr_document_sidecar_spec.rb +1 -0
  65. data/spec/services/spotlight/etl/context_spec.rb +66 -0
  66. data/spec/services/spotlight/etl/executor_spec.rb +149 -0
  67. data/spec/services/spotlight/etl/pipeline_spec.rb +22 -0
  68. data/spec/services/spotlight/etl/solr_loader_spec.rb +76 -0
  69. data/spec/services/spotlight/etl/step_spec.rb +70 -0
  70. data/spec/spec_helper.rb +2 -5
  71. data/spec/views/spotlight/dashboards/_reindexing_activity.html.erb_spec.rb +22 -19
  72. metadata +55 -15
  73. data/app/models/concerns/spotlight/resources/open_graph.rb +0 -36
  74. data/app/models/spotlight/reindexing_log_entry.rb +0 -42
  75. data/app/services/spotlight/resources/iiif_builder.rb +0 -19
  76. data/app/services/spotlight/solr_document_builder.rb +0 -77
  77. data/app/services/spotlight/upload_solr_document_builder.rb +0 -57
  78. data/spec/factories/reindexing_log_entries.rb +0 -54
  79. data/spec/models/spotlight/reindexing_log_entry_spec.rb +0 -129
  80. data/spec/models/spotlight/resources/open_graph_spec.rb +0 -65
  81. data/spec/services/spotlight/solr_document_builder_spec.rb +0 -66
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- describe Spotlight::SolrDocumentBuilder do
4
- let(:exhibit) { FactoryBot.create(:exhibit) }
5
- let(:doc_builder) { described_class.new(resource) }
6
- let(:resource) { Spotlight::Resource.new }
7
-
8
- describe '#to_solr' do
9
- subject { doc_builder.send(:to_solr) }
10
-
11
- before do
12
- allow(resource).to receive(:exhibit).and_return(exhibit)
13
- allow(resource).to receive_messages(type: 'Spotlight::Resource::Something', id: 15, persisted?: true)
14
- end
15
-
16
- it 'includes a reference to the resource' do
17
- expect(subject).to include spotlight_resource_id_ssim: resource.to_global_id.to_s
18
- end
19
- end
20
-
21
- describe '#documents_to_index' do
22
- context 'when the document belongs to more than one exhibit' do
23
- subject { resource.document_builder }
24
-
25
- let(:doc) { SolrDocument.new(id: 'abc123') }
26
- let(:resource) { FactoryBot.create(:resource) }
27
- let(:resource_alt) { FactoryBot.create(:resource) }
28
-
29
- before do
30
- allow(Spotlight::Engine.config).to receive(:filter_resources_by_exhibit).and_return(true)
31
- allow(resource.document_builder).to receive(:to_solr).and_return(id: 'abc123')
32
- allow(resource_alt.document_builder).to receive(:to_solr).and_return(id: 'abc123')
33
- resource_alt.document_builder.documents_to_index.first
34
- end
35
-
36
- it 'has filter data for both exhibits' do
37
- result = resource.document_builder.documents_to_index.first
38
- expect(result).to include "spotlight_exhibit_slug_#{resource.exhibit.slug}_bsi"
39
- expect(result).to include "spotlight_exhibit_slug_#{resource_alt.exhibit.slug}_bsi"
40
- end
41
-
42
- it 'has a field with both exhibit slugs listed' do
43
- result = resource.document_builder.documents_to_index.first
44
- expect(result).to include 'spotlight_exhibit_slugs_ssim' => match_array([resource.exhibit.slug, resource_alt.exhibit.slug])
45
- end
46
-
47
- it 'creates a sidecar resource for the document' do
48
- resource.document_builder.documents_to_index.first
49
-
50
- expect(Spotlight::SolrDocumentSidecar.where(document_id: 'abc123', document_type: 'SolrDocument').size).to eq 2
51
- sidecar = resource.solr_document_sidecars.find_by(document_id: 'abc123', document_type: 'SolrDocument')
52
- expect(sidecar.exhibit).to eq resource.exhibit
53
- expect(sidecar.resource).to eq resource
54
- end
55
-
56
- context 'without a persisted resource' do
57
- let(:resource) { FactoryBot.build(:resource, exhibit: exhibit) }
58
-
59
- it 'does not implicitly persist the resource' do
60
- resource.document_builder.documents_to_index.first
61
- expect(resource).not_to be_persisted
62
- end
63
- end
64
- end
65
- end
66
- end