Class: ProjectDashboardPresenter
Instance Attribute Summary
#project, #project_metadata
Instance Method Summary
collapse
#created, #data_manager, #data_sponsor, #initialize, #project_directory, #updated
Instance Method Details
#last_activity ⇒ Object
28
29
30
31
32
33
34
|
# File 'app/presenters/project_dashboard_presenter.rb', line 28
def last_activity
if project_metadata.updated_on.nil?
"Not yet active"
else
"#{time_ago_in_words(project_metadata.updated_on)} ago"
end
end
|
#latest_file_list_time ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'app/presenters/project_dashboard_presenter.rb', line 17
def latest_file_list_time
requests = FileInventoryRequest.where(project_id: project.id).order(completion_time: :desc)
if requests.empty?
"No Downloads"
elsif requests.first.completion_time
"Prepared #{time_ago_in_words(requests.first.completion_time)} ago"
else
"Preparing now"
end
end
|
#quota_percentage(session_id:) ⇒ Object
59
60
61
62
63
|
# File 'app/presenters/project_dashboard_presenter.rb', line 59
def quota_percentage(session_id:)
return 0 if project.pending? || project.storage_capacity_raw(session_id:).zero?
(project.storage_usage_raw(session_id:).to_f / project.storage_capacity_raw(session_id:).to_f) * 100
end
|
#quota_usage(session_id:) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'app/presenters/project_dashboard_presenter.rb', line 50
def quota_usage(session_id:)
if project.pending?
quota_usage = "0 KB out of 0 GB used"
else
quota_usage = "#{project.storage_usage(session_id:)} out of #{project.storage_capacity(session_id:)} used"
end
quota_usage
end
|
#role(user) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'app/presenters/project_dashboard_presenter.rb', line 40
def role(user)
if == user.uid
"Sponsor"
elsif data_manager == user.uid
"Data Manager"
else
"Data User"
end
end
|
#type ⇒ Object
9
10
11
12
13
14
15
|
# File 'app/presenters/project_dashboard_presenter.rb', line 9
def type
if storage_performance_expectations["approved"].nil?
"Requested #{storage_performance_expectations['requested']}"
else
storage_performance_expectations["approved"]
end
end
|
#updated_at ⇒ Object
36
37
38
|
# File 'app/presenters/project_dashboard_presenter.rb', line 36
def updated_at
project.updated_at
end
|