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

pulibrary / tigerdata-app / f39982ba-1e10-4828-8c7a-16c8e3e17499

07 Nov 2025 04:33PM UTC coverage: 78.985% (-8.2%) from 87.228%
f39982ba-1e10-4828-8c7a-16c8e3e17499

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%)

835 existing lines in 32 files now uncovered.

2537 of 3212 relevant lines covered (78.99%)

278.65 hits per line

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

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

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

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

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

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

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

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

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

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

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

32
    @project_session = "details"
4✔
33

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

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

UNCOV
56
  def show
2✔
UNCOV
57
    return if project.blank?
8✔
58

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

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

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

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

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

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

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

100
    project_job_service.list_contents_job(user: current_user)
1✔
101

UNCOV
102
    json_response = {
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."
1✔
UNCOV
104
    }
105
    render json: json_response
1✔
UNCOV
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." }
×
UNCOV
111
  end
112

UNCOV
113
  def file_list_download
2✔
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 "/"
×
UNCOV
119
    else
120
      filename = user_request.output_file
×
121
      send_data File.read(filename), type: "text/plain", filename: "filelist.csv", disposition: "attachment"
×
UNCOV
122
    end
UNCOV
123
  end
124

UNCOV
125
  private
2✔
126

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

131

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

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

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

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

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

© 2026 Coveralls, Inc