Skip to content

Commit

Permalink
Match progress report - support for duplicates program names (#894)
Browse files Browse the repository at this point in the history
* Update match progress report to handle duplicate program names

* Update mini_portile2; deployments were failing

* Security update for actionpack

* Nicer filter

* Rebuild
  • Loading branch information
eanders authored Dec 30, 2024
1 parent 984d924 commit e01c2c1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ GEM
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
erubi (1.13.0)
erubi (1.13.1)
erubis (2.7.0)
excon (0.111.0)
execjs (2.9.1)
Expand Down Expand Up @@ -482,7 +482,7 @@ GEM
net-protocol
net-ssh (7.2.3)
nio4r (2.7.3)
nokogiri (1.17.1)
nokogiri (1.17.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
notiffany (0.1.3)
Expand Down Expand Up @@ -529,7 +529,7 @@ GEM
rack (>= 1.2.0)
rack-session (1.0.2)
rack (< 3)
rack-test (2.1.0)
rack-test (2.2.0)
rack (>= 1.3)
rails (7.0.8.7)
actioncable (= 7.0.8.7)
Expand Down Expand Up @@ -558,7 +558,7 @@ GEM
activesupport (>= 4.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.6.1)
rails-html-sanitizer (1.6.2)
loofah (~> 2.21)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.0.8.7)
Expand Down
26 changes: 16 additions & 10 deletions app/controllers/reports/match_progress_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def index
respond_to do |format|
format.html {}
format.xlsx do
@included_sub_programs = sub_program_list.invert.slice(*report_params[:sub_programs])
@included_sub_programs = sub_program_list.filter { |_name, sp_id| sp_id.in?(report_params[:sub_programs]) }
filename = 'CAS Match Progress.xlsx'
render xlsx: 'index', filename: filename
end
Expand Down Expand Up @@ -85,20 +85,26 @@ def step_names(sub_program_id)

def sub_programs
@sub_programs ||= SubProgram.
joins(:program).
preload(:program).
pluck(p_t[:name], sp_t[:name], :id).
sort
joins(:program, :match_route).
preload(:program, :match_route).
order(p_t[:name].asc, sp_t[:name].asc, id: :asc).
map do |sp|
{
program: sp.program.name,
sub_program: sp.name,
route: sp.match_route.title,
id: sp.id,
}
end
end
helper_method :sub_programs

def sub_program_list
@sub_program_list ||= sub_programs.map do |project_name, sub_project_name, id|
@sub_program_list ||= sub_programs.map do |sp|
[
[project_name, sub_project_name].join('|'),
id,
[sp[:program], sp[:sub_program], sp[:route]].compact_blank.join('|'),
sp[:id],
]
end.to_h
end.uniq
end
helper_method :sub_program_list

Expand Down
2 changes: 1 addition & 1 deletion app/views/reports/match_progress/index.xlsx.axlsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
wb = xlsx_package.workbook

@included_sub_programs.each.with_index do |(sub_program_id, sub_program_name), i|
@included_sub_programs.each.with_index do |(sub_program_name, sub_program_id), i|
wb.add_worksheet(name: "#{sub_program_name[0..(30 - i.to_s.length)].gsub(/['\*\/\\\?\[\]\:]/, '-')}#{i}") do |sheet|
steps = step_names(sub_program_id)
shown_steps = (2..steps.count - 1)
Expand Down

0 comments on commit e01c2c1

Please sign in to comment.