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

pulibrary / tigerdata-app / e7a92392-be4c-4214-89f9-e70084a3165f

03 Nov 2025 06:52PM UTC coverage: 46.881% (-44.5%) from 91.394%
e7a92392-be4c-4214-89f9-e70084a3165f

Pull #2128

circleci

hectorcorrea
Rubocop
Pull Request #2128: Project Show page now displays metadata straight from Mediaflux

35 of 61 new or added lines in 6 files covered. (57.38%)

764 existing lines in 37 files now uncovered.

1646 of 3511 relevant lines covered (46.88%)

69.44 hits per line

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

42.72
/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

NEW
10
    @presenter = ProjectShowPresenter.new(project, current_user)
×
11

NEW
12
    add_breadcrumb(@presenter.title, project_path)
×
NEW
13
    add_breadcrumb("Details")
×
14

UNCOV
15
    @provenance_events = project.provenance_events.where.not(event_type: ProvenanceEvent::STATUS_UPDATE_EVENT_TYPE)
×
16

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

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

UNCOV
24
    @requested_size = @size[:requested]
×
UNCOV
25
    @requested_unit = @unit[:requested]
×
26

UNCOV
27
    @approved_size = @size[:approved]
×
UNCOV
28
    @approved_unit = @unit[:approved]
×
29

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

UNCOV
34
    @project_session = "details"
×
35

UNCOV
36
    respond_to do |format|
×
UNCOV
37
      format.html do
×
NEW
38
        render
×
39
      end
UNCOV
40
      format.json do
×
UNCOV
41
        render json: project.to_json
×
42
      end
UNCOV
43
      format.xml do
×
UNCOV
44
        render xml: project.to_xml
×
45
      end
46
    end
47
  end
48

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

58
  def show
1✔
59
    return if project.blank?
2✔
60

61
    @presenter = ProjectShowPresenter.new(project, current_user)
2✔
62

63
    add_breadcrumb(@presenter.title, project_path)
2✔
64
    add_breadcrumb("Contents")
2✔
65

66
    @latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last
2✔
67
    @storage_usage = project.storage_usage(session_id: current_user.mediaflux_session)
2✔
68
    @storage_capacity = project.storage_capacity(session_id: current_user.mediaflux_session)
2✔
69

70
    @num_files = project.asset_count(session_id: current_user.mediaflux_session)
2✔
71

72
    @file_list = project.file_list(session_id: current_user.mediaflux_session, size: 100)
2✔
73
    @files = @file_list[:files]
2✔
74
    @files.sort_by!(&:path)
2✔
75

76
    @project_session = "content"
2✔
77
    respond_to do |format|
2✔
78
      format.html { render }
2✔
79
      format.xml { render xml: @project.to_xml }
4✔
80
    end
81
  end
82

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

100
  def list_contents
1✔
UNCOV
101
    return if project.blank?
×
102

UNCOV
103
    project_job_service.list_contents_job(user: current_user)
×
104

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

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

128
  private
1✔
129

130
    def project_job_service
1✔
UNCOV
131
      @project_job_service ||= ProjectJobService.new(project:)
×
132
    end
133

134

135
    def build_new_project
1✔
136
      @project ||= Project.new
×
137
    end
138

139
    def project
1✔
140
      @project ||= begin
12✔
141
        project = Project.find(params[:id])
2✔
142
        if project.user_has_access?(user: current_user)
2✔
143
          project
2✔
144
        else
UNCOV
145
          flash[:alert] = I18n.t(:access_denied)
×
UNCOV
146
          redirect_to dashboard_path
×
UNCOV
147
          nil
×
148
        end
149
      end
150
    end
151

152
    def eligible_editor?
1✔
UNCOV
153
      return true if current_user.eligible_sponsor? or current_user.eligible_manager?
×
154
    end
155

156
    def set_breadcrumbs
1✔
157
      add_breadcrumb("Dashboard",dashboard_path)
5✔
158
    end
159

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