Skip to content

Commit

Permalink
WIP; scaffold for static SPMs
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders committed Jul 31, 2024
1 parent cc92743 commit d80f16f
Show file tree
Hide file tree
Showing 12 changed files with 309,701 additions and 29,245 deletions.
12 changes: 12 additions & 0 deletions db/warehouse/migrate/20240731155357_create_pm_coc_static_spms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreatePmCoCStaticSpms < ActiveRecord::Migration[7.0]
def change
create_table :pm_coc_static_spms do |t|
t.references :goal, null: false, index: true
t.date :report_start, null: false
t.date :report_end, null: false
t.jsonb :data, null: false, default: {}
t.timestamps
t.datetime :deleted_at
end
end
end
338,816 changes: 309,571 additions & 29,245 deletions db/warehouse_structure.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def index

def edit
@pit_counts = @goal.pit_counts.order(pit_date: :desc)
@spms = @goal.static_spms.order(report_start: :desc, report_end: :desc)
end

def create
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
###
# Copyright 2016 - 2024 Green River Data Analysis, LLC
#
# License detail: https://github.com/greenriver/hmis-warehouse/blob/production/LICENSE.md
###

module PerformanceMeasurement::WarehouseReports
class StaticSpmsController < ApplicationController
# include WarehouseReportAuthorization
include AjaxModalRails::Controller
include ArelHelper
before_action :set_goal

def new
@spm = spm_source.new(goal: @goal)
end

def edit
@spm = spm_source.find(params[:id].to_i)
end

def create
@spm = spm_source.create!({ goal: @goal }.merge(spm_params.to_h))
respond_with(@spm, location: edit_performance_measurement_warehouse_reports_goal_config_path(@goal))
end

def destroy
@spm = spm_source.find(params[:id].to_i)
@spm.destroy
respond_with(@goal, location: edit_performance_measurement_warehouse_reports_goal_config_path(@goal))
end

private def set_goal
@goal = goal_source.find(params[:goal_config_id].to_i)
end

private def goal_source
PerformanceMeasurement::Goal
end

private def spm_source
PerformanceMeasurement::StaticSpm
end

def spm_params
params.require(:spm).permit(
:report_start,
:report_end,
)
end

private def flash_interpolation_options
{ resource_name: 'Static SPM' }
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module PerformanceMeasurement
class Goal < GrdaWarehouseBase
acts_as_paranoid
has_many :pit_counts
has_many :static_spms

scope :default, -> do
where(coc_code: :default)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###
# Copyright 2016 - 2024 Green River Data Analysis, LLC
#
# License detail: https://github.com/greenriver/hmis-warehouse/blob/production/LICENSE.md
###

module PerformanceMeasurement
class StaticSpm < GrdaWarehouseBase
self.table_name = :pm_coc_static_spms
acts_as_paranoid

belongs_to :goal
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.d-flex
.ml-auto.mb-4
= link_to new_performance_measurement_warehouse_reports_goal_config_static_spm_path(@goal), class: 'btn btn-secondary', data: { loads_in_ajax_modal: true } do
%i.icon-plus
Add Static SPM for Comparison
%p
You can optionally provide information from historic SPMs. If available These will be shown as the comparison values for values calculated by the SPM for the #{Translation.translate('CoC Performance Measurement Dashboard')} report where the comparison date range matches the entered data.
- if @spms.present?
.card.mb-4
%table.table.table-striped
%thead
%tr
%th Report Start Date
%th Report End Date
%th
%th
%tbody
- @spms.each do |spm|
%tr
%td= spm.report_start
%td= spm.report_end
%td
= link_to edit_performance_measurement_warehouse_reports_goal_config_static_spm_path(@goal, spm), class: 'btn btn-sm btn-secondary', data: { loads_in_ajax_modal: true } do
%i.icon-pencil
Edit
%td
= link_to performance_measurement_warehouse_reports_goal_config_static_spm_path(@goal, spm), method: :delete, class: 'btn btn-sm btn-icon-only btn-danger', data: { confirm: "Are you sure you want to remove the static SPM (#{spm.report_start} - #{spm.report_end})?"} do
%i.icon-cross
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
%h2 PIT Counts
.well
= render 'pit_counts'
%h2 Static SPMs
.well
= render 'static_spms'
%h2 Specific Goals
.card
%table.table.c-table--indicator.mb-0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
= f.input :report_start, as: :date_picker, label: 'SPM Start Date'
= f.input :report_end, as: :date_picker, label: 'SPM End Date'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- title = Translation.translate('Edit Static SPM for Comparison Calculations')
- content_for :modal_title, title
= simple_form_for @spm, as: :spm, url: performance_measurement_warehouse_reports_goal_config_static_spm_path(@goal, @spm) do |f|
= render 'form', f: f

= f.button :submit, 'Update Static SPM'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- title = Translation.translate('Add a Static SPM for Comparison Calculations')
- content_for :modal_title, title
= simple_form_for @spm, as: :spm, url: performance_measurement_warehouse_reports_goal_config_static_spms_path(@goal) do |f|
= render 'form', f: f

= f.button :submit, 'Add Static SPM'
1 change: 1 addition & 0 deletions drivers/performance_measurement/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
end
resources :goal_configs, except: [:show] do
resources :pit_counts, only: [:new, :create, :destroy]
resources :static_spms, except: [:show]
post :duplicate, on: :member
end
end
Expand Down

0 comments on commit d80f16f

Please sign in to comment.