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

pulibrary / tigerdata-app / 62b73c47-d7c3-42d1-89ea-d5a910c801c1

29 Oct 2025 08:18PM UTC coverage: 87.65% (-3.7%) from 91.355%
62b73c47-d7c3-42d1-89ea-d5a910c801c1

push

circleci

web-flow
Upgrade to mediaflux_dev v0.17.0 (#2118)

Co-authored-by: Hector Correa <hector_correa@princeton.edu>

1 of 1 new or added line in 1 file covered. (100.0%)

941 existing lines in 40 files now uncovered.

2697 of 3077 relevant lines covered (87.65%)

426.44 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
UNCOV
2
class ProjectsController < ApplicationController
3✔
3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

UNCOV
57
    @project_session = "details"
15✔
58

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

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

UNCOV
81
  def show
3✔
82

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

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

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

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

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

105
  # GET "projects/:id/:id-mf"
106
  #
107
  # This action is used to render the mediaflux metadata for a project.
UNCOV
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✔
UNCOV
114
      end
UNCOV
115
    end
UNCOV
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✔
UNCOV
120
  end
121

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

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

UNCOV
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."
3✔
UNCOV
129
    }
UNCOV
130
    render json: json_response
3✔
UNCOV
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." }
×
UNCOV
136
  end
137

UNCOV
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 "/"
×
UNCOV
144
    else
145
      filename = user_request.output_file
×
146
      send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
×
UNCOV
147
    end
UNCOV
148
  end
149

UNCOV
150
  private
3✔
151

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

156

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

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

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

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

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

© 2025 Coveralls, Inc