Skip to content

Commit

Permalink
Merge branch 'release-151' into martha/5752-join-hh
Browse files Browse the repository at this point in the history
  • Loading branch information
martha committed Feb 6, 2025
2 parents 7f337a8 + cf61a7b commit f2e9e4f
Show file tree
Hide file tree
Showing 167 changed files with 2,110 additions and 713 deletions.
10 changes: 1 addition & 9 deletions .github/rspec_buckets.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,6 @@
"average": 0.6751237092105263,
"location": "./drivers/hud_path_report/spec/models/fy2021/question_twenty_six_spec.rb:16"
},
{
"count": 4,
"start": "2024-07-20T16:36:53.099+00:00",
"description": "Prepend Organization IDs",
"total_time": 12.343842105,
"average": 3.08596052625,
"location": "./drivers/hmis_csv_twenty_twenty/spec/models/prepend_organization_ids_spec.rb:9"
},
{
"count": 12,
"start": "2024-07-20T16:59:17.391+00:00",
Expand Down Expand Up @@ -463,4 +455,4 @@
}
]
}
]
]
5 changes: 3 additions & 2 deletions app/controllers/api/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def index
:id,
:ProjectName, # OK to use non-confidentialized name because list is filtered by confidentiality in project_scope
:ProjectType,
:RRHSubType,
o_t[:OrganizationName],
o_t[:id],
ds_t[:short_name],
).each do |id, p_name, type, o_name, o_id, ds_name|
).each do |id, p_name, type, rrh_sub_type, o_name, o_id, ds_name|
o_name_at_ds = "#{o_name} at #{ds_name}"
@data[[o_id, o_name_at_ds]] ||= []

p_name += " (#{HudUtility2024.project_type_brief(type)})" if HudUtility2024.project_type_brief(type).present?
p_name += " (#{HudUtility2024.brief_project_type_with_sub_type(type, rrh_sub_type)})" if HudUtility2024.brief_project_type_with_sub_type(type).present?
@data[[o_id, o_name_at_ds]] << [
p_name,
id,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/anomalies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def flash_interpolation_options
end

protected def title_for_show
"#{@client.name} - Anomalies"
"#{@client.pii_provider(user: current_user).full_name} - Anomalies"
end

private def anomaly_params
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/audits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ def set_client
end

def title_for_show
"#{@client.name} - Audit"
"#{@client.pii_provider(user: current_user).full_name} - Audit"
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/cas_readiness_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def cas_readiness_params
end

def title_for_show
"#{@client.name} - CAS Readiness"
"#{@client.pii_provider(user: current_user).full_name} - CAS Readiness"
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/chronic_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def cas_readiness_params
end

def title_for_show
"#{@client.name} - Chronic"
"#{@client.pii_provider(user: current_user).full_name} - Chronic"
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def update
end

private def title_for_show
"#{@client.name} - #{Translation.translate('Coordinated Entry Assessment')}"
"#{@client.pii_provider(user: current_user).full_name} - #{Translation.translate('Coordinated Entry Assessment')}"
end

def flash_interpolation_options
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/enrollment_history_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def history_scope
end

def title_for_show
"#{@client.name} - Historical Enrollments"
"#{@client.pii_provider(user: current_user).full_name} - Historical Enrollments"
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def file_source
end

protected def title_for_show
"#{@client.name} - Files"
"#{@client.pii_provider(user: current_user).full_name} - Files"
end

def window_visible?(visibility)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/hud_lots_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def index
end

private def title_for_show
"#{@client.name} - Client-Level System Use & Length of Time Homeless Report"
"#{@client.pii_provider(user: current_user).full_name} - Client-Level System Use & Length of Time Homeless Report"
end
helper_method :title_for_show

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def destroy
end

private def title_for_show
"#{@client.name} - Notes"
"#{@client.pii_provider(user: current_user).full_name} - Notes"
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/clients/releases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def pre_populated

private def render_pdf!
@pdf = true
file_name = "Release of Information for #{@client.name}"
file_name = "Release of Information for #{@client.pii_provider(user: current_user).full_name}"
send_data roi_pdf(file_name), filename: "#{file_name}.pdf", type: 'application/pdf'
end

Expand Down Expand Up @@ -175,7 +175,7 @@ def file_source
end

protected def title_for_show
"#{@client.name} - Release of Information"
"#{@client.pii_provider(user: current_user).full_name} - Release of Information"
end

def window_visible?(_visibility)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/clients/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def set_user
end

protected def title_for_show
"#{@client.name} - Relationships"
"#{@client.pii_provider(user: current_user).full_name} - Relationships"
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/vispdats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def destroy_file
end

private def title_for_show
"#{@client.name} - VI-SPDATs"
"#{@client.pii_provider(user: current_user).full_name} - VI-SPDATs"
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/clients/youth/intakes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def remove_all_youth_data
@client.youth_follow_ups.destroy_all
# TODO: This does not remove the client from the Youth DataSource

flash[:notice] = "All Youth information for #{@client.name} has been removed."
flash[:notice] = "All Youth information for #{@client.pii_provider(user: current_user).full_name} has been removed."
redirect_to client_youth_intakes_path(@client)
else
not_authorized!
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cohorts/client_notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def cohort_id
end

def flash_interpolation_options
{ resource_name: "Note for #{@note.client.name}" }
{ resource_name: "Note for #{@note.client.pii_provider(user: current_user).full_name}" }
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/cohorts/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def destroy
else
log_removal(@client.cohort_id, @client.id, params.dig(:grda_warehouse_cohort_client, :reason))
if @client.destroy
flash[:notice] = "Removed #{@client.name}"
flash[:notice] = "Removed #{@client.pii_provider(user: current_user).full_name}"
redirect_to cohort_path(@cohort)
else
render :pre_destroy
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cohorts/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def cohort_id
end

def flash_interpolation_options
{ resource_name: "Note for #{@note.client.name}" }
{ resource_name: "Note for #{@note.client.pii_provider(user: current_user).full_name}" }
end
end
end
3 changes: 2 additions & 1 deletion app/controllers/cohorts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def create

# If the user doesn't have All Cohorts access, grant them access to the cohort
@cohort.replace_access(current_user, scope: :editor)
@cohort.replace_access(current_user, scope: :viewer)
# Always add the cohort to the system group
AccessGroup.maintain_system_groups(group: :cohorts)
# Add default tabs
Expand All @@ -150,7 +151,7 @@ def create
end
end
# Search the list so you can see the newly created cohort
redirect_to cohorts_path('q[name_cont]' => @cohort.name)
redirect_to cohorts_path('search_form[q]' => @cohort.name)
rescue Exception => e
flash[:error] = e.message
redirect_to cohorts_path
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/activity_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def log_activity

# override as necessary in the controller
protected def title_for_show
return @client.name if @client.present?
return @client.pii_provider(user: current_user).full_name if @client.present?
return @user.name if @user.present?
end

Expand Down
40 changes: 40 additions & 0 deletions app/controllers/import_thresholds_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
###
# Copyright 2016 - 2025 Green River Data Analysis, LLC
#
# License detail: https://github.com/greenriver/hmis-warehouse/blob/production/LICENSE.md
###

class ImportThresholdsController < ApplicationController
include AjaxModalRails::Controller
before_action :require_can_view_imports_projects_or_organizations!, only: [:show]
before_action :data_source
before_action :import_threshold

def show
end

def update
import_threshold.update!(import_threshold_params)
respond_with(import_threshold, location: data_source_import_threshold_path)
end

private def import_threshold_params
params.require(:grda_warehouse_import_threshold).
permit(*GrdaWarehouse::ImportThreshold.known_params)
end

private def data_source_scope
GrdaWarehouse::DataSource.viewable_by(current_user, permission: :can_view_projects)
end

private def data_source
@data_source ||= data_source_scope.find_safely(params[:data_source_id])
end
helper_method :data_source

# Ensure the import threshold is saved so the related notifications can be added
private def import_threshold
@import_threshold ||= data_source.import_threshold || GrdaWarehouse::ImportThreshold.create!(data_source_id: data_source.id)
end
helper_method :import_threshold
end
66 changes: 66 additions & 0 deletions app/controllers/notification_configurations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
###
# Copyright 2016 - 2025 Green River Data Analysis, LLC
#
# License detail: https://github.com/greenriver/hmis-warehouse/blob/production/LICENSE.md
###

class NotificationConfigurationsController < ApplicationController
include AjaxModalRails::Controller
before_action :require_can_view_imports_projects_or_organizations!, only: [:show]
before_action :data_source
before_action :import_threshold

def new
@form_url = data_source_import_threshold_notification_configurations_path(notification_slug: import_threshold.valid_notification_slug(params[:notification_slug]))
end

def edit
@form_url = data_source_import_threshold_notification_configuration_path(notification_slug: import_threshold.valid_notification_slug(params[:notification_slug]))
end

def create
notification_configuration.update!(notification_configuration_params.merge(notification_slug: import_threshold.valid_notification_slug(params[:notification_slug])))
respond_with(notification_configuration, location: data_source_import_threshold_path)
end

def update
notification_configuration.update!(notification_configuration_params)
respond_with(notification_configuration, location: data_source_import_threshold_path)
end

def destroy
notification_configuration.destroy!
respond_with(notification_configuration, location: data_source_import_threshold_path)
end

private def notification_configuration_params
params.require(:grda_warehouse_notification_configuration).
permit(:user_id, :active)
end

private def data_source_scope
GrdaWarehouse::DataSource.viewable_by(current_user, permission: :can_view_projects)
end

private def data_source
@data_source ||= data_source_scope.find(params[:data_source_id].to_i)
end
helper_method :data_source

private def import_threshold
@import_threshold ||= data_source.import_threshold
end
helper_method :import_threshold

def notification_configuration
@notification_configuration ||= if params[:id].present?
GrdaWarehouse::NotificationConfiguration.find_safely(params[:id])
else
GrdaWarehouse::NotificationConfiguration.new(
source: import_threshold,
notification_slug: import_threshold.valid_notification_slug(params[:notification_slug]),
)
end
end
helper_method :notification_configuration
end
6 changes: 5 additions & 1 deletion app/controllers/project_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def index

def new
@project_group = project_group_source.new
set_access
set_group_access
end

def create
Expand Down Expand Up @@ -166,6 +166,10 @@ def set_project_group

def set_access
@editor_ids = @project_group.editable_access_control.user_ids
set_group_access
end

def set_group_access
# TODO: START_ACL remove when ACL transition complete
@groups = @project_group.access_groups
@group_ids = @project_group.access_group_ids
Expand Down
11 changes: 11 additions & 0 deletions app/mailers/notify_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,15 @@ def new_account_created(new_user)
mail(to: user.email, subject: 'Account Created')
end
end

def import_processing
@user = params[:user]
@import = params[:import_log_id]
@data_source = params[:data_source]
@error = params[:error]
@count = params[:count]
@paused = params[:paused]
subject = 'HMIS Import Status Update'
mail(to: @user.email, subject: subject)
end
end
11 changes: 11 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ class ApplicationRecord < ActiveRecord::Base

connects_to database: { writing: :primary, reading: :primary }

def self.find_safely(tainted_id)
safe_id = begin
Integer(tainted_id)
rescue ArgumentError, TypeError
nil
end
raise(ActiveRecord::RecordNotFound, "#{sti_name} Record not found for ID: #{tainted_id}") unless safe_id

find(safe_id)
end

def self.needs_migration?
ActiveRecord::Migration.check_pending!
end
Expand Down
6 changes: 4 additions & 2 deletions app/models/concerns/service_history/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def wait_for_processing(interval: 30, max_wait_seconds: DEFAULT_MAX_WAIT_SECONDS
else
started = Time.current
while builder_batch_job_scope.exists?
break if (Time.current - started) > max_wait_seconds
return if (Time.current - started) > max_wait_seconds

sleep(interval)
end
Expand Down Expand Up @@ -121,7 +121,9 @@ def clients_still_processing?(client_ids:)

# Class method
private def builder_batch_job_scope
Delayed::Job.where(failed_at: nil).jobs_for_class('ServiceHistory::RebuildEnrollments')
Delayed::Job.uncached do
Delayed::Job.where(failed_at: nil).jobs_for_class('ServiceHistory::RebuildEnrollments')
end
end

# Class method
Expand Down
Loading

0 comments on commit f2e9e4f

Please sign in to comment.