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

pulibrary / pdc_describe / cace366a-ffad-45f1-9b60-678e607fa527

14 May 2024 02:21PM UTC coverage: 60.862% (-35.0%) from 95.908%
cace366a-ffad-45f1-9b60-678e607fa527

push

circleci

jrgriffiniii
wip

1 of 3 new or added lines in 2 files covered. (33.33%)

1194 existing lines in 57 files now uncovered.

2076 of 3411 relevant lines covered (60.86%)

22.71 hits per line

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

27.59
/app/models/background_upload_snapshot.rb
1
# frozen_string_literal: true
2
class BackgroundUploadSnapshot < UploadSnapshot
1✔
3
  def store_files(uploaded_files, pre_existing_files: [], current_user: nil)
1✔
UNCOV
4
    save # needed so I can point to this snapshot in the files to distinguish new files from existing ones froma past snapshot
×
UNCOV
5
    self.files = uploaded_files.map do |file|
×
UNCOV
6
      { "filename" => prefix_filename(file.original_filename),
×
7
        "upload_status" => "started", user_id: current_user&.id, snapshot_id: id }
8
    end
UNCOV
9
    files.concat pre_existing_files if pre_existing_files.present?
×
10
  end
11

12
  def mark_complete(filename, checksum)
1✔
UNCOV
13
    index = files.index { |file| file["filename"] == prefix_filename(filename) }
×
UNCOV
14
    if index.nil?
×
15
      Rails.logger.error("Uploaded a file that was not part of the orginal Upload: #{id} for work #{work_id}: #{filename}")
×
16
      Honeybadger.notify("Uploaded a file that was not part of the orginal Upload: #{id} for work #{work_id}: #{filename}")
×
17
    else
UNCOV
18
      files[index]["upload_status"] = "complete"
×
UNCOV
19
      files[index]["checksum"] = checksum
×
20
    end
UNCOV
21
    finalize_upload if upload_complete?
×
UNCOV
22
    save
×
23
  end
24

25
  def upload_complete?
1✔
UNCOV
26
    files.select { |file| file.keys.include?("upload_status") }.map { |file| file["upload_status"] }.uniq == ["complete"]
×
27
  end
28

29
  def existing_files
1✔
UNCOV
30
    super.select { |file| file["upload_status"].nil? || file["upload_status"] == "complete" }
×
31
  end
32

33
  def new_files
1✔
UNCOV
34
    files.select { |file| file["snapshot_id"] == id }
×
35
  end
36

37
  def finalize_upload
1✔
UNCOV
38
    new_files.each do |file|
×
UNCOV
39
      work.track_change(:added, file["filename"])
×
40
    end
UNCOV
41
    work.log_file_changes(new_files.first["user_id"])
×
42
  end
43

44
  def prefix_filename(filename)
1✔
UNCOV
45
    if filename.include?(work.prefix)
×
UNCOV
46
      filename
×
47
    else
UNCOV
48
      "#{work.prefix}#{filename}"
×
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