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

pulibrary / tigerdata-app / b10fccf6-5ec9-4665-936f-349cab0ca8ed

28 Oct 2025 02:06PM UTC coverage: 87.382% (-3.9%) from 91.294%
b10fccf6-5ec9-4665-936f-349cab0ca8ed

Pull #2057

circleci

hectorcorrea
Force a change
Pull Request #2057: Dashboard displays projects straights from Mediaflux

49 of 69 new or added lines in 4 files covered. (71.01%)

930 existing lines in 39 files now uncovered.

2694 of 3083 relevant lines covered (87.38%)

296.77 hits per line

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

97.22
/app/presenters/project_xml_presenter.rb
1
# frozen_string_literal: true
2

3
# rubocop:disable Metrics/ClassLength
UNCOV
4
class ProjectXmlPresenter
2✔
UNCOV
5
  attr_reader :project, :project_metadata
2✔
6

7
  # Delegate methods to the project and project_metadata objects
UNCOV
8
  delegate(
2✔
UNCOV
9
    "id",
UNCOV
10
    "in_mediaflux?",
UNCOV
11
    "mediaflux_id",
UNCOV
12
    "title",
UNCOV
13
    to: :project
UNCOV
14
  )
15

UNCOV
16
  delegate(
2✔
UNCOV
17
    "approval_note",
UNCOV
18
    "description",
UNCOV
19
    "data_manager",
UNCOV
20
    "data_sponsor",
UNCOV
21
    "data_user_read_only",
UNCOV
22
    "data_user_read_write",
UNCOV
23
    "departments",
UNCOV
24
    "project_id",
UNCOV
25
    "project_purpose",
UNCOV
26
    "storage_capacity",
UNCOV
27
    "storage_performance_expectations",
UNCOV
28
    "created_by",
UNCOV
29
    "created_on",
UNCOV
30
    "updated_by",
UNCOV
31
    "updated_on",
UNCOV
32
    "schema_version",
UNCOV
33
    to: :project_metadata
UNCOV
34
  )
35

36
  # @param project [Project] The project for the presenter
UNCOV
37
  def initialize(project)
2✔
UNCOV
38
    @project = project
54✔
UNCOV
39
    @project_metadata = @project.metadata_model
54✔
UNCOV
40
  end
41

42
  # @return [Nokogiri::XML::Document] The XML document
UNCOV
43
  delegate :document, to: :build
2✔
44

45
  # @return [Boolean] Whether the request for a Globus mount is approved
UNCOV
46
  def globus_enable_approved?
2✔
UNCOV
47
    project_metadata.globus_request == "Yes"
130✔
UNCOV
48
  end
49

50
  # @return [String] Whether the request for a Globus mount is approved
UNCOV
51
  def globus_enable_approved
2✔
UNCOV
52
    if globus_enable_approved?
127✔
53
      "true"
1✔
UNCOV
54
    else
UNCOV
55
      "false"
126✔
UNCOV
56
    end
UNCOV
57
  end
58

59
  # @return [Boolean] Whether there is a request for a Globus mount
UNCOV
60
  def globus_enable_requested?
2✔
UNCOV
61
    project_metadata.globus_request == "Yes"
46✔
UNCOV
62
  end
63

64
  # @return [String] Whether the request for a Globus mount is requested
UNCOV
65
  def globus_enable_requested
2✔
UNCOV
66
    if globus_enable_requested?
44✔
67
      "true"
1✔
UNCOV
68
    else
UNCOV
69
      "false"
43✔
UNCOV
70
    end
UNCOV
71
  end
72

73
  # @return [Boolean] Whether the request for the SMB mount is approved
UNCOV
74
  def smb_enable_approved?
2✔
UNCOV
75
    project_metadata.smb_request == "Yes"
130✔
UNCOV
76
  end
77

78
  # @return [String] Whether the request for the SMB mount is approved
UNCOV
79
  def smb_enable_approved
2✔
UNCOV
80
    if smb_enable_approved?
84✔
81
      "true"
1✔
UNCOV
82
    else
UNCOV
83
      "false"
83✔
UNCOV
84
    end
UNCOV
85
  end
86

87
  # @return [Boolean] Whether there is a request for SMB mount
UNCOV
88
  def smb_enable_requested?
2✔
UNCOV
89
    project_metadata.smb_request == "Yes"
42✔
UNCOV
90
  end
91

92
  # @return [String] Whether the request for the SMB mount is requested
UNCOV
93
  def smb_enable_requested
2✔
UNCOV
94
    if smb_enable_requested?
41✔
95
      "true"
×
UNCOV
96
    else
UNCOV
97
      "false"
41✔
UNCOV
98
    end
UNCOV
99
  end
100

101
  # @return [String] The project status (mapped to values specified by the TigerData XML schema)
102
  # NOTE: Valid values are one of: 'AdminReview', 'Approved', 'Active', 'Retired', 'Published'
UNCOV
103
  def status
2✔
UNCOV
104
    project_status = project.status
41✔
UNCOV
105
    return if project_status.nil?
41✔
106

UNCOV
107
    project_status.capitalize
41✔
UNCOV
108
  end
109

110
  # @return [ProvenanceEvent] The first project submission event
UNCOV
111
  def submission
2✔
UNCOV
112
    @submission ||= project.provenance_events.find_by(event_type: ProvenanceEvent::SUBMISSION_EVENT_TYPE)
199✔
UNCOV
113
  end
114

115
  # @return [Array<ProvenanceEvent>] The project submission events
UNCOV
116
  def submissions
2✔
UNCOV
117
    [submission]
41✔
UNCOV
118
  end
119

120
  # @return [String] The user ID of the user who requested the project
UNCOV
121
  def requested_by
2✔
UNCOV
122
    return if submission.nil?
42✔
123

124
    submission.event_person
37✔
UNCOV
125
  end
126

127
  # @return [String] The date and time of the request
UNCOV
128
  def request_date_time
2✔
UNCOV
129
    return if submission.nil?
42✔
130

131
    value = submission.created_at
37✔
132
    value.strftime("%Y-%m-%dT%H:%M:%S%:z")
37✔
UNCOV
133
  end
134

135
  # @return [String] The user ID of the user who approved the project
UNCOV
136
  def approved_by
2✔
UNCOV
137
    return if approval_note.nil?
42✔
138

139
    approval_note[:note_by]
3✔
UNCOV
140
  end
141

142
  # @return [String] The date and time of the approval
UNCOV
143
  def approval_date_time
2✔
UNCOV
144
    return nil if approval_note.nil?
42✔
145

146
    approval_note[:note_date_time]
3✔
UNCOV
147
  end
148

149
  # @return [String] Whether or not the project data use agreement
UNCOV
150
  def data_use_agreement?
2✔
UNCOV
151
    project_metadata.data_use_agreement.present?
42✔
UNCOV
152
  end
153

154
  # @return [String] The project resource type
UNCOV
155
  def project_resource_type
2✔
UNCOV
156
    project_metadata.resource_type
42✔
UNCOV
157
  end
158

159
  # @return [Boolean] Whether the project is provisional
UNCOV
160
  def provisional_project?
2✔
UNCOV
161
    project_metadata.provisional
42✔
UNCOV
162
  end
163

164
  # @return [String] Whether or not the project is associated with HPC
UNCOV
165
  delegate :hpc, to: :project_metadata
2✔
166

167
  # @return [String] The project visibility
UNCOV
168
  delegate :project_visibility, to: :project_metadata
2✔
169

170
  # @return [Boolean] Whether the project directory request is approved
UNCOV
171
  def project_directory_approved?
2✔
UNCOV
172
    expectations = storage_performance_expectations
41✔
UNCOV
173
    expectations[:approved] || false
41✔
UNCOV
174
  end
175

176
  # @return [Boolean] Whether the project storage capacity request is approved
UNCOV
177
  def storage_capacity_approved?
2✔
UNCOV
178
    storage_capacity_size = storage_capacity["size"] || {}
41✔
UNCOV
179
    return false unless storage_capacity_size.key?(:approved)
41✔
180

UNCOV
181
    approved_size = storage_capacity_size[:approved] || 0
5✔
UNCOV
182
    approved_size > 0
5✔
UNCOV
183
  end
184

185
  # @return [Boolean] Whether the project storage request is approved
UNCOV
186
  def storage_performance_requested?
2✔
UNCOV
187
    requested = storage_performance_expectations[:requested]
41✔
UNCOV
188
    requested.present?
41✔
UNCOV
189
  end
190

191
  # @return [Array<String>] The project directory paths
UNCOV
192
  def project_directory
2✔
UNCOV
193
    [project.project_directory]
126✔
UNCOV
194
  end
195

196
  # @param index [Integer] The index of the project directory
197
  # @return [String] The project directory path
UNCOV
198
  def project_directory_path(index)
2✔
UNCOV
199
    entry = project_directory[index]
41✔
UNCOV
200
    entry
41✔
UNCOV
201
  end
202

203
  # @param index [Integer] The index of the project directory
204
  # @return [String] The protocol for the project directory
UNCOV
205
  def project_directory_protocol(index)
2✔
UNCOV
206
    entry = project_directory[index]
42✔
UNCOV
207
    segments = entry.split("://")
42✔
208

UNCOV
209
    if segments.length > 1
42✔
210
      value = segments[0]
×
211
      value.upcase
×
UNCOV
212
    else
UNCOV
213
      ProjectMetadata.default_directory_protocol
42✔
UNCOV
214
    end
UNCOV
215
  end
216

217
  # @param index [Integer] The index of the department code to retrieve
218
  # @return [String] The department code for departments associated with the project
UNCOV
219
  def department(index)
2✔
UNCOV
220
    value = departments[index]
46✔
UNCOV
221
    if value.length < 6
46✔
UNCOV
222
      value = value.rjust(6, "0")
46✔
UNCOV
223
    end
UNCOV
224
    value
46✔
UNCOV
225
  end
226

227
  # @return [String] The department code for the project
UNCOV
228
  def department_code(index)
2✔
UNCOV
229
    departments[index]
46✔
UNCOV
230
  end
231

232
  # @return [String] The requested project storage capacity
UNCOV
233
  def requested_storage
2✔
UNCOV
234
    storage_performance_expectations[:requested] || nil
42✔
UNCOV
235
  end
236

UNCOV
237
  private
2✔
238

UNCOV
239
    def xml_builder_config
2✔
UNCOV
240
      Rails.configuration.xml_builder
82✔
UNCOV
241
    end
242

UNCOV
243
    def presenter_builder_config
2✔
UNCOV
244
      xml_builder_config[:project] || {}
82✔
UNCOV
245
    end
246

UNCOV
247
    def find_builder_args(key)
2✔
UNCOV
248
      raise "No builder config for #{key}" unless presenter_builder_config.key?(key)
41✔
249

UNCOV
250
      values = presenter_builder_config[key]
41✔
UNCOV
251
      values[:presenter] = self
41✔
UNCOV
252
      values
41✔
UNCOV
253
    end
254

UNCOV
255
    def builder
2✔
UNCOV
256
      @builder ||= begin
41✔
UNCOV
257
                     builder_args = find_builder_args(:resource)
41✔
UNCOV
258
                     XmlTreeBuilder.new(**builder_args)
41✔
UNCOV
259
                   end
UNCOV
260
    end
261

UNCOV
262
    delegate :build, to: :builder
2✔
UNCOV
263
end
264
# rubocop:enable Metrics/ClassLength
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