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

pulibrary / tigerdata-app / cfc380f0-670d-4daf-b2f2-2265018b5b79

30 Oct 2025 10:22PM UTC coverage: 87.141% (-4.2%) from 91.355%
cfc380f0-670d-4daf-b2f2-2265018b5b79

Pull #2125

circleci

JaymeeH
Replace layout
update request presenter
Pull Request #2125: Change layout of draft request details

3 of 12 new or added lines in 1 file covered. (25.0%)

494 existing lines in 34 files now uncovered.

2697 of 3095 relevant lines covered (87.14%)

299.31 hits per line

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

89.26
/app/controllers/projects_controller.rb
1
# frozen_string_literal: true
2
class ProjectsController < ApplicationController
3✔
3

4
  before_action :set_breadcrumbs
3✔
5
  before_action :authenticate_user!
3✔
6

7
  def details
3✔
UNCOV
8
    return if project.blank?
5✔
9

UNCOV
10
    add_breadcrumb(project.title, project_path)
4✔
UNCOV
11
    add_breadcrumb("Details")
4✔
12

UNCOV
13
    @departments = project.departments.join(", ")
4✔
UNCOV
14
    @project_metadata = project.metadata_model
4✔
15

UNCOV
16
    @data_sponsor = User.find_by(uid: @project_metadata.data_sponsor)
4✔
UNCOV
17
    @data_manager = User.find_by(uid: @project_metadata.data_manager)
4✔
18

UNCOV
19
    read_only_uids = @project_metadata.ro_users
4✔
UNCOV
20
    data_read_only_users = read_only_uids.map { |uid| ReadOnlyUser.find_by(uid:) }.reject(&:blank?)
4✔
21

UNCOV
22
    read_write_uids = @project_metadata.rw_users
4✔
UNCOV
23
    data_read_write_users = read_write_uids.map { |uid| User.find_by(uid:) }.reject(&:blank?)
4✔
24

UNCOV
25
    unsorted_data_users = data_read_only_users + data_read_write_users
4✔
UNCOV
26
    sorted_data_users = unsorted_data_users.sort_by { |u| u.family_name || u.uid }
4✔
UNCOV
27
    @data_users = sorted_data_users.uniq { |u| u.uid }
4✔
UNCOV
28
    user_model_names = @data_users.map(&:display_name_safe)
4✔
UNCOV
29
    @data_user_names = user_model_names.join(", ")
4✔
30

UNCOV
31
    @provenance_events = project.provenance_events.where.not(event_type: ProvenanceEvent::STATUS_UPDATE_EVENT_TYPE)
4✔
32

UNCOV
33
    @project_eligible_to_edit = true if project.status == Project::APPROVED_STATUS && eligible_editor?
4✔
34

UNCOV
35
    @project_metadata = @project.metadata
4✔
UNCOV
36
    @project_id = @project_metadata[:project_id] || {}
4✔
UNCOV
37
    @storage_capacity = @project_metadata[:storage_capacity]
4✔
UNCOV
38
    @size = @storage_capacity[:size]
4✔
UNCOV
39
    @unit = @storage_capacity[:unit]
4✔
40

UNCOV
41
    @requested_size = @size[:requested]
4✔
UNCOV
42
    @requested_unit = @unit[:requested]
4✔
43

UNCOV
44
    @approved_size = @size[:approved]
4✔
UNCOV
45
    @approved_unit = @unit[:approved]
4✔
46

UNCOV
47
    @storage_expectations = @project_metadata[:storage_performance_expectations]
4✔
UNCOV
48
    @requested_storage_expectations = @storage_expectations[:requested]
4✔
UNCOV
49
    @approved_storage_expectations = @storage_expectations[:approved]
4✔
50

UNCOV
51
    @project_purpose = @project_metadata[:project_purpose]
4✔
UNCOV
52
    @number_of_files = @project_metadata[:number_of_files]
4✔
UNCOV
53
    @hpc = @project_metadata[:hpc]
4✔
UNCOV
54
    @smb = @project_metadata[:smb_request]
4✔
UNCOV
55
    @globus = @project_metadata[:globus_request]
4✔
56

UNCOV
57
    @project_session = "details"
4✔
58

UNCOV
59
    respond_to do |format|
4✔
UNCOV
60
      format.html do
4✔
UNCOV
61
        @project = ProjectShowPresenter.new(project)
1✔
62
      end
UNCOV
63
      format.json do
4✔
UNCOV
64
        render json: project.to_json
2✔
65
      end
UNCOV
66
      format.xml do
4✔
UNCOV
67
        render xml: project.to_xml
1✔
68
      end
69
    end
70
  end
71

72
  def index
3✔
UNCOV
73
    if current_user.eligible_sysadmin?
4✔
UNCOV
74
      search_projects
3✔
75
    else
UNCOV
76
      flash[:alert] = I18n.t(:access_denied)
1✔
UNCOV
77
      redirect_to dashboard_path
1✔
78
    end
79
  end
80

81
  def show
3✔
82

UNCOV
83
    return if project.blank?
9✔
UNCOV
84
    add_breadcrumb(project.title, project_path)
8✔
UNCOV
85
    add_breadcrumb("Contents")
8✔
86

UNCOV
87
    @latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last
8✔
UNCOV
88
    @storage_usage = project.storage_usage(session_id: current_user.mediaflux_session)
8✔
UNCOV
89
    @storage_capacity = project.storage_capacity(session_id: current_user.mediaflux_session)
4✔
90

UNCOV
91
    @num_files = project.asset_count(session_id: current_user.mediaflux_session)
4✔
92

UNCOV
93
    @file_list = project.file_list(session_id: current_user.mediaflux_session, size: 100)
4✔
UNCOV
94
    @files = @file_list[:files]
4✔
UNCOV
95
    @files.sort_by!(&:path)
4✔
UNCOV
96
    @project = ProjectShowPresenter.new(project)
4✔
97

UNCOV
98
    @project_session = "content"
4✔
UNCOV
99
    respond_to do |format|
4✔
UNCOV
100
      format.html { render }
6✔
UNCOV
101
      format.xml { render xml: @project.to_xml }
6✔
102
    end
103
  end
104

105
  # GET "projects/:id/:id-mf"
106
  #
107
  # This action is used to render the mediaflux metadata for a project.
108
  def show_mediaflux
3✔
UNCOV
109
    project_id = params[:id]
4✔
UNCOV
110
    project = Project.find(project_id)
4✔
UNCOV
111
    respond_to do |format|
3✔
UNCOV
112
      format.xml do
3✔
UNCOV
113
        render xml: project.mediaflux_meta_xml(user: current_user)
3✔
114
      end
115
    end
116
  rescue => ex
117
    Rails.logger.error "Error getting MediaFlux XML for project #{project_id}, user #{current_user.uid}: #{ex.message}"
1✔
118
    flash[:alert] = "Error fetching Mediaflux XML for this project"
1✔
119
    redirect_to project_path(project_id)
1✔
120
  end
121

122
  def list_contents
3✔
UNCOV
123
    return if project.blank?
2✔
124

UNCOV
125
    project_job_service.list_contents_job(user: current_user)
1✔
126

127
    json_response = {
UNCOV
128
      message: "File list for \"#{project.title}\" is being generated in the background. A link to the downloadable file list will be available in the \"Recent Activity\" section of your dashboard when it is available. You may safely navigate away from this page or close this tab."
1✔
129
    }
UNCOV
130
    render json: json_response
1✔
131
  rescue => ex
132
    message = "Error producing document list (project id: #{project&.id}): #{ex.message}"
×
133
    Rails.logger.error(message)
×
134
    Honeybadger.notify(message)
×
135
    render json: { message: "Document list could not be generated." }
×
136
  end
137

138
  def file_list_download
3✔
139
    job_id = params[:job_id]
×
140
    user_request = FileInventoryRequest.where(job_id:job_id).first
×
141
    if user_request.nil?
×
142
      # TODO: handle error
143
      redirect_to "/"
×
144
    else
145
      filename = user_request.output_file
×
146
      send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
×
147
    end
148
  end
149

150
  private
3✔
151

152
    def project_job_service
3✔
UNCOV
153
      @project_job_service ||= ProjectJobService.new(project:)
1✔
154
    end
155

156

157
    def build_new_project
3✔
158
      @project ||= Project.new
×
159
    end
160

161
    def project
3✔
UNCOV
162
      @project ||= begin
74✔
UNCOV
163
        project = Project.find(params[:id])
14✔
UNCOV
164
        if project.user_has_access?(user: current_user)
14✔
UNCOV
165
          project
11✔
166
        else
UNCOV
167
          flash[:alert] = I18n.t(:access_denied)
3✔
UNCOV
168
          redirect_to dashboard_path
3✔
UNCOV
169
          nil
3✔
170
        end
171
      end
172
    end
173

174
    def eligible_editor?
3✔
UNCOV
175
      return true if current_user.eligible_sponsor? or current_user.eligible_manager?
3✔
176
    end
177

178
    def set_breadcrumbs
3✔
UNCOV
179
      add_breadcrumb("Dashboard",dashboard_path)
28✔
180
    end
181

182
    def search_projects
3✔
UNCOV
183
      @title_query = params[:title_query]
3✔
UNCOV
184
      if @title_query.blank?
3✔
UNCOV
185
        @projects = Project.all
1✔
UNCOV
186
        flash[:notice] = nil
1✔
187
      else
UNCOV
188
        result =  ProjectSearch.new.call(search_string: @title_query, requestor: current_user)
2✔
UNCOV
189
        if result.success?
2✔
UNCOV
190
          flash[:notice] = "Successful search in Mediaflux for #{@title_query}"
2✔
UNCOV
191
          @projects = result.value!
2✔
192
        else
193
          @projects = []
×
194
          flash[:notice] = "Error searching projects for #{@title_query}.  Error: #{result.failure}"
×
195
        end
196
      end
197
    end
198
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

© 2026 Coveralls, Inc