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

pulibrary / pdc_describe / 4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

07 Apr 2025 06:36PM UTC coverage: 1.283% (-94.6%) from 95.862%
4e4e59fc-9df4-4838-9fd4-6c7ea33cdb7c

Pull #1994

circleci

hectorcorrea
Switched to use the autocomplete that we aleady use for ROR. Integrated it with the existing logic for creators
Pull Request #1994: Started adding auto complete to contributors

0 of 46 new or added lines in 2 files covered. (0.0%)

4806 existing lines in 74 files now uncovered.

65 of 5065 relevant lines covered (1.28%)

0.01 hits per line

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

0.0
/app/services/work_update_metadata_service.rb
1
# frozen_string_literal: true
2

3
# A service to update metadata across PDC Describe
UNCOV
4
class WorkUpdateMetadataService
×
UNCOV
5
  RENAMED_PPPL_SUBCOMMUNITIES = [
×
UNCOV
6
    {
×
UNCOV
7
      old: "Plasma Science & Technology",
×
UNCOV
8
      new: "Discovery Plasma Science"
×
UNCOV
9
    }
×
UNCOV
10
  ].freeze
×
11

12
  # For each renamed pppl subcommunity, traverse all of the works
13
  # and update the value
UNCOV
14
  def self.update_pppl_subcommunities(user, commandline: false)
×
UNCOV
15
    Work.all.each do |work|
×
UNCOV
16
      resource_before = work.resource.dup
×
UNCOV
17
      RENAMED_PPPL_SUBCOMMUNITIES.each do |renamed_subcommunity|
×
UNCOV
18
        sc = work.resource.subcommunities
×
UNCOV
19
        next unless sc.include? renamed_subcommunity[:old]
×
UNCOV
20
        puts "Updating work #{work.id}" if commandline
×
UNCOV
21
        work.resource.subcommunities = new_subcommunities(sc, renamed_subcommunity)
×
UNCOV
22
      end
×
UNCOV
23
      work.save
×
UNCOV
24
      resource_after = work.resource
×
UNCOV
25
      resource_compare = ResourceCompareService.new(resource_before, resource_after)
×
UNCOV
26
      WorkActivity.add_work_activity(work.id, resource_compare.differences.to_json, user.id, activity_type: WorkActivity::CHANGES)
×
UNCOV
27
    end
×
UNCOV
28
  end
×
29

30
  # Given a list of subcommunities, and a Hash from RENAMED_PPPL_SUBCOMMUNITIES,
31
  # replace all instances of :old with :new
UNCOV
32
  def self.new_subcommunities(sc, renamed_subcommunity)
×
UNCOV
33
    new_subcommunities = []
×
UNCOV
34
    sc.each do |subcommunity|
×
UNCOV
35
      new_subcommunities << if subcommunity == renamed_subcommunity[:old]
×
UNCOV
36
                              renamed_subcommunity[:new]
×
UNCOV
37
                            else
×
UNCOV
38
                              subcommunity
×
UNCOV
39
                            end
×
UNCOV
40
    end
×
UNCOV
41
    new_subcommunities
×
UNCOV
42
  end
×
UNCOV
43
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