Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 64 #855

Merged
merged 10 commits into from
Oct 4, 2024
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.4)
rexml (3.3.6)
strscan
roo (2.10.1)
nokogiri (~> 1)
Expand Down
23 changes: 0 additions & 23 deletions app/controllers/opportunity_matches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,29 +105,6 @@ def prioritized_column_values(client)
end
helper_method :prioritized_column_values

def priority_labels
supporting_data_columns = @opportunity.match_route.match_prioritization.supporting_data_columns
return supporting_data_columns.keys if supporting_data_columns.present?

[@opportunity.match_route.match_prioritization.title]
end
helper_method :priority_labels

def priority_values(client)
supporting_data_columns = @opportunity.match_route.match_prioritization.supporting_data_columns
return supporting_data_columns.values.map { |fn| fn.call(client) } if supporting_data_columns.present?

fn = @opportunity.match_route.match_prioritization.client_prioritization_summary_method
value = if client.class.column_names.include?(fn.to_s)
client.send(fn)
else
client.send(fn, match_route: @opportunity.match_route)
end

[value]
end
helper_method :priority_values

def match_routes(client)
counts = client.client_opportunity_matches.active.open.
joins(:program, :match_route).
Expand Down
1 change: 1 addition & 0 deletions app/controllers/sub_programs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def sub_program_params
:eligibility_requirement_notes,
:weighting_rules_active,
:cori_hearing_required,
:match_prioritization_id,
)
end

Expand Down
25 changes: 23 additions & 2 deletions app/models/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def default_client_contacts
@default_client_contacts ||= ClientContacts.new client: self
end

def self.prioritized(match_route, scope)
match_route.match_prioritization.prioritization_for_clients(scope)
def self.prioritized(prioritization_scheme, scope)
prioritization_scheme.prioritization_for_clients(scope)
end

# A random number for prioritization that require a tie-breaker
Expand Down Expand Up @@ -380,6 +380,17 @@ def remote_data_source
@remote_data_source ||= project_client&.data_source || false
end

def required_number_of_bedrooms_or_sro_ok
text = required_number_of_bedrooms.to_s
text += ' (SRO OK)' if sro_ok

text
end

def assessment_type_description
NonHmisAssessment.declassify_title(NonHmisAssessment.title_from_type_for_matching(assessment_name))
end

def remote_client_visible_to?(user)
return true unless project_client.is_deidentified? || project_client.is_identified?
return true if NonHmisClient.visible_to(user).where(id: remote_id).exists?
Expand Down Expand Up @@ -1230,6 +1241,16 @@ def self.prioritized_columns_data
description: nil,
type: 'Jsonb',
},
required_number_of_bedrooms_or_sro_ok: {
title: 'Minimum Bedrooms',
description: nil,
type: 'String',
},
assessment_type_description: {
title: 'Assessment Type',
description: nil,
type: 'String',
},
}
end

Expand Down
33 changes: 27 additions & 6 deletions app/models/client_opportunity_match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,37 @@ def current_decision
end

def unsuccessful_decision
initialized_decisions.where.not(decline_reason_id: nil)&.first ||
initialized_decisions.where.not(administrative_cancel_reason_id: nil)&.first
return canceled_decision if canceled?

declined_decision
end

def unsuccessful_reason
return unsuccessful_decision&.administrative_cancel_reason if canceled?

unsuccessful_decision&.decline_reason
end

# Find the latest decision in the route that was declined with a reason
# If that doesn't exist, pull the latest initialized decision that was declined
def declined_decision
@declined_decision ||= initialized_decisions.where.not(decline_reason_id: nil)&.first
@declined_decision ||= initialized_decisions.where(status: :declined)&.last
decision_order = match_route.class.match_steps_for_reporting.keys
@declined_decision ||= initialized_decisions.order_as_specified(type: decision_order).where.not(decline_reason_id: nil)&.last
@declined_decision ||= initialized_decisions.order_as_specified(type: decision_order).where(status: :declined)&.last
@declined_decision
end

# Find the latest decision in the route that was canceled with a reason
# If that doesn't exist, pull the latest initialized decision that was canceled
def canceled_decision
return nil unless canceled?

decision_order = match_route.class.match_steps_for_reporting.keys
@canceled_decision ||= initialized_decisions.order_as_specified(type: decision_order).where.not(administrative_cancel_reason_id: nil)&.last
@canceled_decision ||= initialized_decisions.order_as_specified(type: decision_order).where(status: :canceled)&.last
@canceled_decision
end

def clear_current_decision_cache!
@current_decision = nil
end
Expand Down Expand Up @@ -1021,8 +1042,8 @@ def associated_file_tags
tags.to_h
end

def self.prioritized_by_client(match_route, scope)
match_route.match_prioritization.prioritization_for_clients(scope)
def self.prioritized_by_client(opportunity, scope)
opportunity.active_prioritization_scheme.prioritization_for_clients(scope, opportunity: opportunity)
end

def self.sort_options
Expand Down
6 changes: 6 additions & 0 deletions app/models/concerns/reporting/filter_scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ module Reporting::FilterScopes
scope.program_type(@filter.program_types)
end

private def filter_for_programs(scope)
return scope if @filter.programs.blank?

scope.program(@filter.programs)
end

private def filter_for_agencies(scope)
return scope if @filter.agencies.blank?

Expand Down
8 changes: 7 additions & 1 deletion app/models/concerns/tc_hat_calculations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ def required_number_of_bedrooms
# when 1, 2 # unnecessary, these would result in 1 bedroom
when 3, 4
2
when (5..)
when 5, 6
3
when 7, 8
4
when 9, 10
5
when (11..)
6
else
num
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/match_census.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def self.populate_from_opportunity! opp
# Clear any existing data for this opportunity on this day, and rebuild
where(opportunity_id: opp.id, date: Date.current).delete_all
clients_for_route = Client.available_for_matching(opp.match_route)
match_prioritization = opp.match_route.match_prioritization
match_prioritization = opp.active_prioritization_scheme
# IDs of prioritized clients who match this opportunity, prioritized by route configuration
available_client_ids = opp.matching_clients(clients_for_route).map do |client|
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ def statuses
}
end

def editable?
super && saved_status !~ /accepted|declined/
end

def stallable?
true
end
Expand Down
6 changes: 5 additions & 1 deletion app/models/match_decisions/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def contact_name
def editable?
# can this decision be updated by a notification response?
# override this default behavior in subclasses
initialized? && match_open?
initialized? && match_open? && saved_status !~ /\A(accepted|confirmed|declined|canceled|rejected|complete|completed|scheduled|no_hearing|mitigation_required|mitigation_not_required|decline_overridden|decline_overridden_returned|decline_confirmed)\z/
end

def expires?
Expand All @@ -101,6 +101,10 @@ def stallable?
false
end

def skipped?
false
end

def show_address_field?
match_route.show_address_field
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ def contact_actor_type
nil
end

def editable?
super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/
end

def initialize_decision! send_notifications: true
super(send_notifications: send_notifications)
update status: 'pending'
Expand Down
4 changes: 0 additions & 4 deletions app/models/match_decisions/confirm_match_success_dnd_staff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ def contact_actor_type
nil
end

def editable?
super && status !~ /confirmed|rejected/
end

def initialize_decision! send_notifications: true
super(send_notifications: send_notifications)
update status: 'pending'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

module MatchDecisions
class ConfirmShelterAgencyDeclineDndStaff < Base

def statuses
{
pending: 'Pending',
Expand Down Expand Up @@ -43,10 +42,6 @@ def contact_actor_type
nil
end

def editable?
super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/
end

def permitted_params
super + [:prevent_matching_until]
end
Expand Down Expand Up @@ -97,7 +92,5 @@ def canceled
end
end
private_constant :StatusCallbacks

end

end
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ def contact_actor_type
nil
end

def editable?
super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/
end

def permitted_params
super + [:prevent_matching_until]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ def contact_actor_type
nil
end

def editable?
super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/
end

def permitted_params
super + [:prevent_matching_until]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ def contact_actor_type
nil
end

def editable?
super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/
end

def permitted_params
super + [:prevent_matching_until]
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/match_decisions/eight/eight_assign_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ def started?
status&.to_sym == :completed
end

def editable?
super && saved_status !~ /completed|declined/
end

def accessible_by? contact
contact.user_can_act_on_behalf_of_match_contacts? ||
contact.in?(match.send(contact_actor_type))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ def canceled
end
private_constant :StatusCallbacks

def editable?
super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/
end

def step_decline_reasons(_contact)
[
'Immigration status',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ def contact_actor_type
nil
end

def editable?
super && status !~ /confirmed|rejected/
end

def initialize_decision! send_notifications: true
super(send_notifications: send_notifications)
update status: 'pending'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ def contact_actor_type
nil
end

def editable?
super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/
end

def initialize_decision! send_notifications: true
super(send_notifications: send_notifications)
update status: 'pending'
Expand Down
4 changes: 0 additions & 4 deletions app/models/match_decisions/eight/eight_lease_up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ def started?
status&.to_sym == :completed
end

def editable?
super && saved_status !~ /completed|declined/
end

def accessible_by? contact
contact.user_can_act_on_behalf_of_match_contacts? ||
contact.in?(match.send(contact_actor_type))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ def statuses
}
end

def editable?
super && saved_status !~ /accepted|declined/
end

def permitted_params
super + [:prevent_matching_until, :shelter_expiration]
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/match_decisions/eight/eight_record_voucher_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ def statuses
}
end

def editable?
super && saved_status !~ /accepted|declined/
end

def stallable?
true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ def contact_actor_type
nil
end

def editable?
super && saved_status !~ /decline_overridden|decline_overridden_returned|decline_confirmed/
end

def initialize_decision! send_notifications: true
super(send_notifications: send_notifications)
update status: 'pending'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ def expires?
true
end

def editable?
super && saved_status !~ /accepted|declined/
end

def initialize_decision! send_notifications: true
super(send_notifications: send_notifications)
update status: 'pending'
Expand Down
Loading
Loading