Skip to content

Commit c6b1bd1

Browse files
Merged in r2-2827-reporting-location (pull request #6749)
R2-2827: Using record owner location instead record location for record location insight
2 parents 6bd346c + a4e7d4f commit c6b1bd1

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

app/javascript/components/insights/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const AGENCY = "agency";
7676
export const BY = "by";
7777
export const WORKFLOW = "workflow";
7878
export const PROTECTION_CONCERNS = "protection_concerns";
79-
export const REPORTING_LOCATIONS = "location_current";
79+
export const REPORTING_LOCATIONS = "owned_by_location";
8080
export const FOLLOWUPS = "followup_type";
8181
export const SERVICES = "service_type";
8282
export const VIOLENCE_TYPE = "cp_incident_violence_type";

app/models/managed_report.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def self.list
3838
subreports: %w[reporting_locations],
3939
permitted_filters: [
4040
:grouped_by, :by, :created_by_groups, :owned_by_groups,
41-
:created_organization, :owned_by_agency_id, :location_current, { status: {}, registration_date: {} }
41+
:created_organization, :owned_by_agency_id, :owned_by_location, { status: {}, registration_date: {} }
4242
],
4343
module_id: PrimeroModule::CP
4444
),

app/models/managed_reports/indicators/field_by_age_sex.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def sql(current_user, params = {})
5555
#{equal_value_query(params['module_id'])&.prepend('and ')}
5656
#{field_value(params[field_name])&.prepend('and ')}
5757
#{user_scope_query(current_user)&.prepend('and ')}
58-
#{reporting_location_query(params['location_current'])&.prepend('and ')}
58+
#{reporting_location_query(params['owned_by_location'])&.prepend('and ')}
5959
group by name, key
6060
#{grouped_date_query(params['grouped_by'], date_param)&.prepend(', ')}
6161
order by name, key

app/models/managed_reports/indicators/reporting_location_by_sex_and_age.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def id
1010
end
1111

1212
def field_name
13-
'location_current'
13+
'owned_by_location'
1414
end
1515

1616
def reporting_location_field?

app/models/managed_reports/sql_query_helpers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ def reporting_location_query(param, _table_name = nil, _hash_field = 'data', map
6262
[
6363
%(
6464
(
65-
data->>:field_name = :param_value AND data->>:field_name IS NOT NULL AND EXISTS
65+
data ? :field_name AND data->>:field_name IS NOT NULL AND EXISTS
6666
(
6767
SELECT
6868
1
6969
FROM locations
7070
INNER JOIN locations AS descendants
7171
ON locations.admin_level <= descendants.admin_level
7272
AND locations.hierarchy_path @> descendants.hierarchy_path
73-
WHERE locations.location_code = data->>:field_name AND descendants.location_code = data->>:field_name
73+
WHERE locations.location_code = :param_value AND descendants.location_code = data->>:field_name
7474
)
7575
)
7676
),

0 commit comments

Comments
 (0)