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

pulibrary / pdc_describe / 9091a1ae-29be-458c-984a-339d213919c4

12 Dec 2024 07:41PM UTC coverage: 26.434% (-69.7%) from 96.113%
9091a1ae-29be-458c-984a-339d213919c4

Pull #2000

circleci

jrgriffiniii
Removing integration with ActiveStorage
Pull Request #2000: Bump actionpack from 7.2.1.1 to 7.2.2.1

945 of 3575 relevant lines covered (26.43%)

0.35 hits per line

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

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

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

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

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