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

pulibrary / tigerdata-app / 5761a836-7ce0-47df-9302-d25fe3ceed83

01 Dec 2025 10:02PM UTC coverage: 67.957% (-3.6%) from 71.597%
5761a836-7ce0-47df-9302-d25fe3ceed83

Pull #2250

circleci

JaymeeH
fixing typo
Pull Request #2250: Organize the submission provenance for a project

8 of 31 new or added lines in 2 files covered. (25.81%)

416 existing lines in 25 files now uncovered.

2265 of 3333 relevant lines covered (67.96%)

193.38 hits per line

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

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

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

7
  def details
1✔
UNCOV
8
    return if project.blank?
×
9

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

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

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

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

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

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

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

UNCOV
32
    @project_session = "details"
×
33

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

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

56
  def show
1✔
57
    return if project.blank?
1✔
58

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

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

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

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

72
    @project_session = "content"
1✔
73
    respond_to do |format|
1✔
74
      format.html { render }
1✔
75
      format.xml { render xml: ProjectShowPresenter.new(project, current_user).to_xml
2✔
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
1✔
84
    project_id = params[:id]
1✔
85
    project = Project.find(project_id)
1✔
86
    respond_to do |format|
1✔
87
      format.xml do
1✔
88
        render xml: project.mediaflux_meta_xml(user: current_user)
1✔
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}"
×
93
    flash[:alert] = "Error fetching Mediaflux XML for this project"
×
94
    redirect_to project_path(project_id)
×
95
  end
96

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

UNCOV
100
    project_job_service.list_contents_job(user: current_user)
×
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."
×
104
    }
UNCOV
105
    render json: json_response
×
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
1✔
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
1✔
126

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

131

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

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

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

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

158
    def search_projects
1✔
UNCOV
159
      @title_query = if params[:title_query].present?
×
UNCOV
160
        params[:title_query]
×
161
      else
UNCOV
162
        "*" # default to all projects
×
163
      end
UNCOV
164
      result =  ProjectSearch.new.call(search_string: @title_query, requestor: current_user)
×
UNCOV
165
      if result.success?
×
UNCOV
166
        flash[:notice] = "Successful search in Mediaflux for #{@title_query}"
×
167
        # As of today the search results and the Dashboard show similar information (a list of projects)
168
        # and it makes sense to use the same presenter. If once we flesh out the search feature the
169
        # results become too different from each other we can create a specific presenter for the search
170
        # results.
UNCOV
171
        @project_presenters = result.value!.map { |project| ProjectDashboardPresenter.new(project, current_user) }
×
172
      else
173
        flash[:notice] = "Error searching projects for #{@title_query}.  Error: #{result.failure}"
×
174
        @project_presenters = []
×
175
      end
176
    end
177
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