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

pulibrary / tigerdata-app / 7711d404-e0db-4645-a677-49882cb6642f

06 Nov 2025 07:33PM UTC coverage: 91.087% (-0.1%) from 91.201%
7711d404-e0db-4645-a677-49882cb6642f

Pull #2163

circleci

web-flow
Merge branch 'main' into 2157-project-list-error
Pull Request #2163: Logs Mediaflux errors when fetching the project list

5 of 8 new or added lines in 1 file covered. (62.5%)

916 existing lines in 36 files now uncovered.

2841 of 3119 relevant lines covered (91.09%)

547.1 hits per line

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

87.25
/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?
16✔
9

UNCOV
10
    add_breadcrumb(@presenter.title, project_path)
14✔
UNCOV
11
    add_breadcrumb("Details")
14✔
12

UNCOV
13
    @provenance_events = project.provenance_events.where.not(event_type: ProvenanceEvent::STATUS_UPDATE_EVENT_TYPE)
14✔
14

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

UNCOV
17
    @project_metadata = @project.metadata
14✔
UNCOV
18
    @storage_capacity = @project_metadata[:storage_capacity]
14✔
UNCOV
19
    @size = @storage_capacity[:size]
14✔
UNCOV
20
    @unit = @storage_capacity[:unit]
14✔
21

UNCOV
22
    @requested_size = @size[:requested]
14✔
UNCOV
23
    @requested_unit = @unit[:requested]
14✔
24

UNCOV
25
    @approved_size = @size[:approved]
14✔
UNCOV
26
    @approved_unit = @unit[:approved]
14✔
27

UNCOV
28
    @storage_expectations = @project_metadata[:storage_performance_expectations]
14✔
UNCOV
29
    @requested_storage_expectations = @storage_expectations[:requested]
14✔
UNCOV
30
    @approved_storage_expectations = @storage_expectations[:approved]
14✔
31

UNCOV
32
    @project_session = "details"
14✔
33

UNCOV
34
    respond_to do |format|
14✔
UNCOV
35
      format.html do
14✔
UNCOV
36
        render
11✔
37
      end
UNCOV
38
      format.json do
14✔
UNCOV
39
        render json: project.to_json
2✔
40
      end
UNCOV
41
      format.xml do
14✔
UNCOV
42
        render xml: @presenter.to_xml
1✔
43
      end
44
    end
45
  end
46

47
  def index
3✔
UNCOV
48
    if current_user.eligible_sysadmin?
10✔
UNCOV
49
      search_projects
6✔
50
    else
UNCOV
51
      flash[:alert] = I18n.t(:access_denied)
4✔
UNCOV
52
      redirect_to dashboard_path
4✔
53
    end
54
  end
55

56
  def show
3✔
UNCOV
57
    return if project.blank?
39✔
58

UNCOV
59
    add_breadcrumb(@presenter.title, project_path)
29✔
UNCOV
60
    add_breadcrumb("Contents")
29✔
61

UNCOV
62
    @latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last
29✔
UNCOV
63
    @storage_usage = project.storage_usage(session_id: current_user.mediaflux_session)
29✔
UNCOV
64
    @storage_capacity = project.storage_capacity(session_id: current_user.mediaflux_session)
29✔
65

UNCOV
66
    @num_files = project.asset_count(session_id: current_user.mediaflux_session)
29✔
67

UNCOV
68
    @file_list = project.file_list(session_id: current_user.mediaflux_session, size: 100)
29✔
UNCOV
69
    @files = @file_list[:files]
29✔
UNCOV
70
    @files.sort_by!(&:path)
29✔
71

UNCOV
72
    @project_session = "content"
29✔
UNCOV
73
    respond_to do |format|
29✔
UNCOV
74
      format.html { render }
53✔
UNCOV
75
      format.xml { render xml: ProjectShowPresenter.new(project, current_user).to_xml
34✔
76
    }
77
    end
78
  end
79

80
  # GET "projects/:id/:id-mf"
81
  #
82
  # This action is used to render the mediaflux metadata for a project.
83
  def show_mediaflux
3✔
UNCOV
84
    project_id = params[:id]
4✔
UNCOV
85
    project = Project.find(project_id)
4✔
UNCOV
86
    respond_to do |format|
3✔
UNCOV
87
      format.xml do
3✔
UNCOV
88
        render xml: project.mediaflux_meta_xml(user: current_user)
3✔
89
      end
90
    end
91
  rescue => ex
92
    Rails.logger.error "Error getting MediaFlux XML for project #{project_id}, user #{current_user.uid}: #{ex.message}"
1✔
93
    flash[:alert] = "Error fetching Mediaflux XML for this project"
1✔
94
    redirect_to project_path(project_id)
1✔
95
  end
96

97
  def list_contents
3✔
UNCOV
98
    return if project.blank?
4✔
99

UNCOV
100
    project_job_service.list_contents_job(user: current_user)
3✔
101

102
    json_response = {
UNCOV
103
      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✔
104
    }
UNCOV
105
    render json: json_response
3✔
106
  rescue => ex
107
    message = "Error producing document list (project id: #{project&.id}): #{ex.message}"
×
108
    Rails.logger.error(message)
×
109
    Honeybadger.notify(message)
×
110
    render json: { message: "Document list could not be generated." }
×
111
  end
112

113
  def file_list_download
3✔
114
    job_id = params[:job_id]
×
115
    user_request = FileInventoryRequest.where(job_id:job_id).first
×
116
    if user_request.nil?
×
117
      # TODO: handle error
118
      redirect_to "/"
×
119
    else
120
      filename = user_request.output_file
×
121
      send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
×
122
    end
123
  end
124

125
  private
3✔
126

127
    def project_job_service
3✔
UNCOV
128
      @project_job_service ||= ProjectJobService.new(project:)
3✔
129
    end
130

131

132
    def build_new_project
3✔
133
      @project ||= Project.new
×
134
    end
135

136
    def project
3✔
UNCOV
137
      @project ||= begin
216✔
UNCOV
138
        project = Project.find(params[:id])
59✔
UNCOV
139
        @presenter = ProjectShowPresenter.new(project, current_user)
59✔
UNCOV
140
        if project&.mediaflux_id != nil && @presenter.user_has_access?(user: current_user)
55✔
UNCOV
141
          project
46✔
142
        else
UNCOV
143
          flash[:alert] = I18n.t(:access_denied)
9✔
UNCOV
144
          redirect_to dashboard_path
9✔
UNCOV
145
          nil
9✔
146
        end
147
      end
148
    end
149

150
    def eligible_editor?
3✔
151
      return true if current_user.eligible_sponsor? or current_user.eligible_manager?
3✔
152
    end
153

154
    def set_breadcrumbs
3✔
UNCOV
155
      add_breadcrumb("Dashboard",dashboard_path)
79✔
156
    end
157

158
    def search_projects
3✔
UNCOV
159
      @title_query = params[:title_query]
6✔
UNCOV
160
      if @title_query.blank?
6✔
UNCOV
161
        @projects = Project.all
2✔
UNCOV
162
        flash[:notice] = nil
2✔
163
      else
UNCOV
164
        result =  ProjectSearch.new.call(search_string: @title_query, requestor: current_user)
4✔
UNCOV
165
        if result.success?
4✔
UNCOV
166
          flash[:notice] = "Successful search in Mediaflux for #{@title_query}"
4✔
UNCOV
167
          @projects = result.value!
4✔
168
        else
169
          @projects = []
×
170
          flash[:notice] = "Error searching projects for #{@title_query}.  Error: #{result.failure}"
×
171
        end
172
      end
173
    end
174
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