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

pulibrary / tigerdata-app / da06f62a-2e8b-4995-ae49-246e33b0661f

03 Nov 2025 07:07PM UTC coverage: 91.368% (-0.03%) from 91.4%
da06f62a-2e8b-4995-ae49-246e33b0661f

Pull #2126

circleci

bess
Bump tar in the npm_and_yarn group across 1 directory

Bumps the npm_and_yarn group with 1 update in the / directory: [tar](https://github.com/isaacs/node-tar).


Updates `tar` from 7.5.1 to 7.5.2
- [Release notes](https://github.com/isaacs/node-tar/releases)
- [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/isaacs/node-tar/compare/v7.5.1...v7.5.2)

---
updated-dependencies:
- dependency-name: tar
  dependency-version: 7.5.2
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #2126: Bump tar from 7.5.1 to 7.5.2 in the npm_and_yarn group across 1 directory

2826 of 3093 relevant lines covered (91.37%)

486.76 hits per line

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

97.37
/app/presenters/project_show_presenter.rb
1
# frozen_string_literal: true
2
class ProjectShowPresenter
5✔
3
  delegate "id", "in_mediaflux?", "mediaflux_id", "status", to: :project
5✔
4
  delegate "project_id", "storage_performance_expectations", to: :project_metadata
5✔
5

6
  attr_reader :project, :project_metadata
5✔
7

8
  # @return [Class] The presenter class for building XML Documents from Projects
9
  def self.xml_presenter_class
5✔
10
    ProjectXmlPresenter
9✔
11
  end
12

13
  # While we are transitioning to fetching the data straight from Mediaflux `project` can be
14
  # an ActiveRecord Project model (when used from the Project show page) or a Hash with the
15
  # data from Mediaflux (when used from the Dashboard).
16
  # This branching can be refactored (elimitated?) once we implement ticket
17
  # https://github.com/pulibrary/tigerdata-app/issues/2039 and the project data will always
18
  # come from Mediaflux.
19
  def initialize(project)
5✔
20
    if project.is_a?(Hash)
1,053✔
21
      @project_mf = project
980✔
22
      @project = rails_project(@project_mf)
980✔
23
    else
24
      @project_mf = nil
73✔
25
      @project = project
73✔
26
    end
27
    @project_metadata = @project&.metadata_model
1,053✔
28
  end
29

30
  def title
5✔
31
    if @project_mf.nil?
200✔
32
      @project.title
48✔
33
    else
34
      @project_mf[:title]
152✔
35
    end
36
  end
37

38
  def description
5✔
39
    if @project_mf.nil?
48✔
40
      @project.metadata_model.description
48✔
41
    else
42
      @project_mf[:description]
×
43
    end
44
  end
45

46
  # @return [String] the XML for the project Document
47
  def to_xml
5✔
48
    xml_document.to_xml
8✔
49
  end
50

51
  # @return [Nokogiri::XML::Document] the XML Document for the Project
52
  def xml_document
5✔
53
    @xml_document ||= xml_presenter.document
9✔
54
  end
55

56
  def created
5✔
57
    @project.created_at.strftime("%b %e, %Y %l:%M %p")
34✔
58
  end
59

60
  def updated
5✔
61
    @project.updated_at.strftime("%b %e, %Y %l:%M %p")
34✔
62
  end
63

64
  def data_sponsor
5✔
65
    if @project_mf.nil?
189✔
66
      User.find_by(uid: @project.metadata["data_sponsor"]).uid
34✔
67
    else
68
      User.find_by(uid: @project_mf[:data_sponsor])&.uid
155✔
69
    end
70
  end
71

72
  def data_manager
5✔
73
    if @project_mf.nil?
108✔
74
      User.find_by(uid: @project.metadata["data_manager"]).uid
34✔
75
    else
76
      User.find_by(uid: @project_mf[:data_manager])&.uid
74✔
77
    end
78
  end
79

80
  def project_purpose
5✔
81
    if @project_mf.nil?
2✔
82
      project_metadata.project_purpose
2✔
83
    else
84
      @project_mf[:project_purpose]
×
85
    end
86
  end
87

88
  # used to hide the project root that is not visible to the end user
89
  def project_directory
5✔
90
    project.project_directory.gsub(Mediaflux::Connection.hidden_root, "")
14✔
91
  end
92

93
  def storage_capacity(session_id: nil)
5✔
94
    return project_metadata.storage_capacity if session_id.nil?
36✔
95

96
    persisted = project.storage_capacity_raw(session_id: session_id)
34✔
97
    value = persisted.to_f
34✔
98

99
    value*default_capacity_divisor
34✔
100
  end
101

102
  def formatted_storage_capacity(session_id:)
5✔
103
    value = storage_capacity(session_id: session_id)
34✔
104
    format("%.3f", value)
34✔
105
  end
106

107
  def formatted_quota_percentage(session_id:)
5✔
108
    value = quota_percentage(session_id:)
34✔
109
    format("%.3f", value)
34✔
110
  end
111

112
  def quota_usage(session_id:)
5✔
113
    "#{project.storage_usage(session_id:)} out of #{project.storage_capacity(session_id:)} used"
186✔
114
  end
115

116
  def quota_percentage(session_id:)
5✔
117
    storage_capacity = project.storage_capacity_raw(session_id:)
144✔
118
    return 0 if storage_capacity.zero?
144✔
119

120
    storage_usage = project.storage_usage_raw(session_id:)
132✔
121
    (storage_usage.to_f / storage_capacity.to_f) * 100
132✔
122
  end
123

124
  def project_in_rails?
5✔
125
    project != nil
980✔
126
  end
127

128
  private
5✔
129

130
    # Capacity is in bytes
131
    def default_capacity_divisor
5✔
132
      1.0/(1000.0**3)
34✔
133
    end
134

135
    def xml_presenter_args
5✔
136
      project
9✔
137
    end
138

139
    def xml_presenter
5✔
140
      @xml_presenter ||= self.class.xml_presenter_class.new(xml_presenter_args)
9✔
141
    end
142

143
    def rails_project(project_mf)
5✔
144
      database_record = Project.where(mediaflux_id:project_mf[:mediaflux_id]).first
980✔
145
      if database_record.nil?
980✔
146
        Rails.logger.warn("Mediaflux project with ID #{project_mf[:mediaflux_id]} is not in the Rails database (title: #{project_mf[:title]})")
891✔
147
        Honeybadger.notify("Mediaflux project with ID #{project_mf[:mediaflux_id]} is not in the Rails database (title: #{project_mf[:title]})")
891✔
148
      end
149
      database_record
980✔
150
    end
151
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