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

pulibrary / tigerdata-app / bb6442c4-eb43-430c-9683-6ffb5848882a

21 Oct 2025 08:43PM UTC coverage: 87.325% (+0.4%) from 86.877%
bb6442c4-eb43-430c-9683-6ffb5848882a

Pull #2066

circleci

bess
Stop mediaflux when we stop everything else
Pull Request #2066: Stop mediaflux when we stop everything else

2625 of 3006 relevant lines covered (87.33%)

307.22 hits per line

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

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

6
  attr_reader :project, :project_metadata
2✔
7

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

13
  def initialize(project)
2✔
14
    @project = project
134✔
15
    @project_metadata = @project.metadata_model
134✔
16
  end
17

18
  # @return [String] the XML for the project Document 
19
  def to_xml
2✔
20
    xml_document.to_xml
5✔
21
  end
22

23
  # @return [Nokogiri::XML::Document] the XML Document for the Project
24
  def xml_document
2✔
25
    @xml_document ||= xml_presenter.document
5✔
26
  end
27

28
  def created
2✔
29
    @project.created_at.strftime("%b %e, %Y %l:%M %p")
33✔
30
  end
31

32
  def updated
2✔
33
    @project.updated_at.strftime("%b %e, %Y %l:%M %p")
33✔
34
  end
35

36
  def data_sponsor
2✔
37
    User.find_by(uid: @project.metadata["data_sponsor"]).uid
33✔
38
  end
39

40
  def data_manager
2✔
41
    User.find_by(uid: @project.metadata["data_manager"]).uid
33✔
42
  end
43

44
  # used to hide the project root that is not visible to the end user
45
  def project_directory
2✔
46
    project.project_directory.gsub(Mediaflux::Connection.hidden_root, "")
11✔
47
  end
48

49
  def storage_capacity(session_id: nil)
2✔
50
    return project_metadata.storage_capacity if session_id.nil?
33✔
51

52
    persisted = project.storage_capacity_raw(session_id: session_id)
33✔
53
    value = persisted.to_f
33✔
54

55
    value*default_capacity_divisor
33✔
56
  end
57

58
  def formatted_storage_capacity(session_id:)
2✔
59
    value = storage_capacity(session_id: session_id)
33✔
60
    format("%.3f", value)
33✔
61
  end
62

63
  def formatted_quota_percentage(session_id:)
2✔
64
    value = quota_percentage(session_id:)
33✔
65
    format("%.3f", value)
33✔
66
  end
67

68
  def quota_usage(session_id:)
2✔
69
    "#{project.storage_usage(session_id:)} out of #{project.storage_capacity(session_id:)} used"
217✔
70
  end
71

72
  def quota_percentage(session_id:)
2✔
73
    storage_capacity = project.storage_capacity_raw(session_id:)
158✔
74
    return 0 if storage_capacity.zero?
158✔
75

76
    storage_usage = project.storage_usage_raw(session_id:)
41✔
77
    (storage_usage.to_f / storage_capacity.to_f) * 100
41✔
78
  end
79

80
  private
2✔
81

82
    # Capacity is in bytes
83
    def default_capacity_divisor
2✔
84
      1.0/(1000.0**3)
33✔
85
    end
86

87
    def xml_presenter_args
2✔
88
      project
5✔
89
    end
90

91
    def xml_presenter
2✔
92
      @xml_presenter ||= self.class.xml_presenter_class.new(xml_presenter_args)
5✔
93
    end
94
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