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

pulibrary / tigerdata-app / 6308ea0a-4c93-4778-8ca0-734eed0ee653

09 Dec 2024 03:43PM UTC coverage: 84.149% (-0.06%) from 84.211%
6308ea0a-4c93-4778-8ca0-734eed0ee653

push

circleci

web-flow
Refining progress bar (#1095)

* updating dashboard presenter so quota usage has its own pending message

* calculating the quota usage percentage based on the raw bytes of used and allocated storage

* Update app/presenters/project_dashboard_presenter.rb

Co-authored-by: carolyncole <1599081+carolyncole@users.noreply.github.com>

---------

Co-authored-by: carolyncole <1599081+carolyncole@users.noreply.github.com>

4 of 4 branches covered (100.0%)

15 of 19 new or added lines in 3 files covered. (78.95%)

2235 of 2656 relevant lines covered (84.15%)

331.07 hits per line

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

96.97
/app/presenters/project_dashboard_presenter.rb
1
# frozen_string_literal: true
2
class ProjectDashboardPresenter < ProjectShowPresenter
1✔
3
  include ActionView::Helpers::DateHelper
1✔
4

5
  delegate :to_model, to: :project
1✔
6

7
  delegate :data_sponsor, :data_manager, to: :project_metadata
1✔
8

9
  def type
1✔
10
    if storage_performance_expectations["approved"].nil?
61✔
11
      "Requested #{storage_performance_expectations['requested']}"
58✔
12
    else
13
      storage_performance_expectations["approved"]
3✔
14
    end
15
  end
16

17
  def latest_file_list_time
1✔
18
    requests = FileInventoryRequest.where(project_id: project.id).order(completion_time: :desc)
61✔
19
    if requests.empty?
61✔
20
      "No Downloads"
60✔
21
    else
22
      "Prepared #{time_ago_in_words(requests.first.completion_time)} ago"
1✔
23
    end
24
  end
25

26
  def last_activity
1✔
27
    if project_metadata.updated_on.nil?
60✔
28
      "Not yet active"
4✔
29
    else
30
      "#{time_ago_in_words(project_metadata.updated_on)} ago"
56✔
31
    end
32
  end
33

34
  def updated_at
1✔
35
    project.updated_at
59✔
36
  end
37

38
  def role(user)
1✔
39
    if data_sponsor == user.uid
59✔
40
      "Sponsor"
13✔
41
    elsif data_manager == user.uid
46✔
42
      "Data Manager"
7✔
43
    else
44
      "Data User"
39✔
45
    end
46
  end
47

48
  def quota_usage(session_id:)
1✔
49
    if project.pending?
59✔
50
      quota_usage = "0 KB out of 0 GB used"
56✔
51
    else
52
      quota_usage = "#{project.storage_usage(session_id:)} out of #{project.storage_capacity(session_id:)} used"
3✔
53
    end
54
    quota_usage
59✔
55
  end
56

57
  def quota_percentage(session_id:)
1✔
58
    return 0 if project.pending? || project.storage_capacity_raw(session_id:).zero?
59✔
59
    
NEW
60
   (project.storage_usage_raw(session_id:).to_f / project.storage_capacity_raw(session_id:).to_f) * 100
×
61
  end
62
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