dscf-credit 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/dscf/credit/facilitator_applications_controller.rb +2 -2
- data/app/controllers/dscf/credit/facilitators_controller.rb +7 -3
- data/app/controllers/dscf/credit/scoring_parameters_controller.rb +1 -1
- data/app/controllers/dscf/credit/users_controller.rb +21 -8
- data/app/services/dscf/credit/credit_scoring_engine.rb +31 -25
- data/lib/dscf/credit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c8471bd555308d0b88c282f893299234859a46f02ae02c003f02b147115e1ae
|
4
|
+
data.tar.gz: 3becd29b404c498ff195e300afa0c313a00155cb20d2ec600f39da1d36e1a45e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c205f203030be0f10872f4dcc1dac30b3ad797abe5a006a071bd579459bd13bf95fb821144d86f96c021e8eb1b7494e1544b6a046eb7b67150484cfeb7910116
|
7
|
+
data.tar.gz: 4910b18be7d23f314940a74e70b2cf1e032b8134e50903ed1770283e5a363af87b5986f32d0308799620326fda211c123a735747d4d9eedd240c958153b87d66
|
@@ -102,7 +102,7 @@ module Dscf::Credit
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def eager_loaded_associations
|
105
|
-
[ :user, :bank, reviews: { reviewed_by: :user_profile } ]
|
105
|
+
[ :user, :bank, { user: { businesses: :business_type } }, reviews: { reviewed_by: :user_profile } ]
|
106
106
|
end
|
107
107
|
|
108
108
|
def allowed_order_columns
|
@@ -111,7 +111,7 @@ module Dscf::Credit
|
|
111
111
|
|
112
112
|
def default_serializer_includes
|
113
113
|
{
|
114
|
-
default: [ :user, :bank, reviews: { reviewed_by: :user_profile } ]
|
114
|
+
default: [ :user, :bank, { user: { businesses: :business_type } }, reviews: { reviewed_by: :user_profile } ]
|
115
115
|
}
|
116
116
|
end
|
117
117
|
end
|
@@ -10,7 +10,9 @@ module Dscf::Credit
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def eager_loaded_associations
|
13
|
-
[
|
13
|
+
[
|
14
|
+
{ facilitator_application: { user: { businesses: :business_type } } },
|
15
|
+
reviews: { reviewed_by: :user_profile } ]
|
14
16
|
end
|
15
17
|
|
16
18
|
def allowed_order_columns
|
@@ -19,8 +21,10 @@ module Dscf::Credit
|
|
19
21
|
|
20
22
|
def default_serializer_includes
|
21
23
|
{
|
22
|
-
index: [ :
|
23
|
-
|
24
|
+
index: [ { facilitator_application: { user: { businesses: :business_type } } },
|
25
|
+
reviews: { reviewed_by: :user_profile } ],
|
26
|
+
show: [ { facilitator_application: { user: { businesses: :business_type } } },
|
27
|
+
reviews: { reviewed_by: :user_profile } ],
|
24
28
|
create: [ :reviews ],
|
25
29
|
update: [ :facilitator_application, reviews: { reviewed_by: :user_profile } ]
|
26
30
|
}
|
@@ -62,7 +62,7 @@ module Dscf::Credit
|
|
62
62
|
|
63
63
|
def default_serializer_includes
|
64
64
|
{
|
65
|
-
index: [ :bank, :category, :parameter_normalizers, reviews: { reviewed_by: :user_profile } ],
|
65
|
+
index: [ :bank, :category, :parameter_normalizers, :scoring_param_type, reviews: { reviewed_by: :user_profile } ],
|
66
66
|
show: [
|
67
67
|
:bank, :category, :created_by, :scoring_param_type, :previous_version, :parameter_normalizers,
|
68
68
|
reviews: { reviewed_by: :user_profile }
|
@@ -16,15 +16,28 @@ module Dscf::Credit
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
users = @clazz
|
20
|
+
.joins(businesses: :business_type)
|
21
|
+
.where(dscf_core_business_types: { id: business_type.id })
|
22
|
+
.where(
|
23
|
+
<<-SQL.squish
|
24
|
+
NOT EXISTS (
|
25
|
+
SELECT 1
|
26
|
+
FROM dscf_credit_facilitator_applications fa
|
27
|
+
WHERE fa.user_id = dscf_core_users.id
|
28
|
+
AND NOT EXISTS (
|
29
|
+
SELECT 1
|
30
|
+
FROM dscf_core_reviews r
|
31
|
+
WHERE r.reviewable_type = 'Dscf::Credit::FacilitatorApplication'
|
32
|
+
AND r.reviewable_id = fa.id
|
33
|
+
AND r.status = 'rejected'
|
34
|
+
)
|
35
|
+
)
|
36
|
+
SQL
|
37
|
+
)
|
38
|
+
.distinct
|
23
39
|
|
24
|
-
|
25
|
-
.where(dscf_core_business_types: { name: business_type_name })
|
26
|
-
.where(id: rejected_user_ids)
|
27
|
-
.distinct
|
40
|
+
users
|
28
41
|
else
|
29
42
|
@clazz.all
|
30
43
|
end
|
@@ -107,41 +107,47 @@ module Dscf::Credit
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def extract_parameter_value(parameter)
|
110
|
-
param_type_name = parameter.scoring_param_type.name
|
111
110
|
parameter_id = parameter.id.to_s
|
112
111
|
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
all_json_fields = {
|
113
|
+
user_info: loan_application.user_info || {},
|
114
|
+
bank_info: loan_application.bank_info || {},
|
115
|
+
facilitator_info: loan_application.facilitator_info || {},
|
116
|
+
field_assessment: loan_application.field_assessment || {}
|
117
|
+
}
|
118
|
+
|
119
|
+
param_data = nil
|
120
|
+
found_in_field = nil
|
121
|
+
|
122
|
+
all_json_fields.each do |field_name, field_data|
|
123
|
+
if field_data.key?(parameter_id)
|
124
|
+
param_data = field_data[parameter_id]
|
125
|
+
found_in_field = field_name
|
126
|
+
break # Stop at first match (IDs should be unique across fields)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
if param_data.nil?
|
131
|
+
Rails.logger.warn "Parameter #{parameter_id} (#{parameter.name}) not found in any JSON field for loan_app #{loan_application.id}"
|
132
|
+
return nil
|
133
|
+
end
|
116
134
|
|
117
|
-
|
118
|
-
|
119
|
-
|
135
|
+
unless param_data.is_a?(Hash)
|
136
|
+
Rails.logger.warn "Invalid param_data for #{parameter_id} in #{found_in_field}: expected Hash, got #{param_data.class}"
|
137
|
+
return nil
|
138
|
+
end
|
120
139
|
|
121
|
-
# Validate
|
140
|
+
# Validate param_name matches (optional safety check)
|
122
141
|
expected_param_name = param_data["param_name"]
|
123
142
|
if expected_param_name && expected_param_name != parameter.name
|
124
|
-
Rails.logger.warn "Parameter name mismatch for ID #{parameter_id}: expected '#{parameter.name}', got '#{expected_param_name}'"
|
143
|
+
Rails.logger.warn "Parameter name mismatch for ID #{parameter_id} in #{found_in_field}: expected '#{parameter.name}', got '#{expected_param_name}'"
|
125
144
|
end
|
126
145
|
|
127
|
-
param_data["value"]
|
146
|
+
raw_value = param_data["value"]
|
147
|
+
Rails.logger.debug "Extracted #{parameter.name} (ID #{parameter_id}) from #{found_in_field}: value=#{raw_value}"
|
148
|
+
raw_value
|
128
149
|
end
|
129
150
|
|
130
|
-
def get_json_field_for_param_type(param_type_name)
|
131
|
-
case param_type_name.downcase
|
132
|
-
when "user_info"
|
133
|
-
loan_application.user_info || {}
|
134
|
-
when "bank_info"
|
135
|
-
loan_application.bank_info || {}
|
136
|
-
when "facilitator_info"
|
137
|
-
loan_application.facilitator_info || {}
|
138
|
-
when "field_assessment"
|
139
|
-
loan_application.field_assessment || {}
|
140
|
-
else
|
141
|
-
Rails.logger.warn "Unknown parameter type: #{param_type_name}"
|
142
|
-
nil
|
143
|
-
end
|
144
|
-
end
|
145
151
|
|
146
152
|
def normalize_parameter_value(parameter, raw_value)
|
147
153
|
return 0.0 if raw_value.nil?
|
data/lib/dscf/credit/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dscf-credit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adoniyas
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-10-
|
10
|
+
date: 2025-10-07 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: dscf-core
|