Skip to content

Commit

Permalink
UHF-9569: UHF-9569: Fix deprecated usage of administrative_division e…
Browse files Browse the repository at this point in the history
…ndpoint

service_point_id- and unit-fields will be removed in the future. They
should be replaced with the use of "units" field. The deprecated fields
will stop appearing in the api results some time soon.
  • Loading branch information
hyrsky committed Mar 22, 2024
1 parent c2eec06 commit 714b430
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AppSettings = {
index: 'health_stations',
locationsBaseUrl: 'https://api.hel.fi/servicemap/v2/administrative_division/?municipality=helsinki&type=health_station_district&unit_include=id',
locationsBaseUrl: 'https://api.hel.fi/servicemap/v2/administrative_division/?municipality=helsinki&type=health_station_district',
size: 15
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import configurationsAtom from '../store';
import getQueryString from '../helpers/ProximityQuery';
import AppSettings from '../enum/AppSettings';

type Unit = {
id?: number
type Result = {
units?: number[]
};

const UseProximityQuery = (params: SearchParams) => {
Expand Down Expand Up @@ -45,7 +45,7 @@ const UseProximityQuery = (params: SearchParams) => {
return null;
}

ids = locationsData.results.map((result: { unit: Unit }) => result.unit.id);
ids = locationsData.results.flatMap((result: Result) => result.units ?? []);
}

return fetch(`${baseUrl}/${index}/_search`, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AppSettings = {
index: 'maternity_and_child_health_clinic',
locationsBaseUrl: 'https://api.hel.fi/servicemap/v2/administrative_division/?municipality=helsinki&type=maternity_clinic_district&unit_include=id',
locationsBaseUrl: 'https://api.hel.fi/servicemap/v2/administrative_division/?municipality=helsinki&type=maternity_clinic_district',
size: 15
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import configurationsAtom from '../store';
import getQueryString from '../helpers/ProximityQuery';
import AppSettings from '../enum/AppSettings';

type Unit = {
id?: number
type Result = {
units?: number[]
};

const UseProximityQuery = (params: SearchParams) => {
Expand Down Expand Up @@ -45,7 +45,7 @@ const UseProximityQuery = (params: SearchParams) => {
return null;
}

ids = locationsData.results.map((result: { unit: Unit }) => result.unit.id);
ids = locationsData.results.flatMap((result: Result) => result.units ?? []);
}

return fetch(`${baseUrl}/${index}/_search`, {
Expand Down
2 changes: 1 addition & 1 deletion src/js/react/apps/school-search/enum/AppSettings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const AppSettings = {
index: 'schools',
locationsBaseUrl: 'https://api.hel.fi/servicemap/v2/administrative_division/?municipality=helsinki&unit_include=id&type=lower_comprehensive_school_district_fi,lower_comprehensive_school_district_sv,upper_comprehensive_school_district_fi,upper_comprehensive_school_district_sv',
locationsBaseUrl: 'https://api.hel.fi/servicemap/v2/administrative_division/?municipality=helsinki&type=lower_comprehensive_school_district_fi,lower_comprehensive_school_district_sv,upper_comprehensive_school_district_fi,upper_comprehensive_school_district_sv',
size: 15
};

Expand Down
6 changes: 3 additions & 3 deletions src/js/react/apps/school-search/hooks/UseProximityQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import configurationsAtom from '../store';
import getQueryString from '../helpers/ProximityQuery';
import AppSettings from '../enum/AppSettings';

type Unit = {
id?: number
type Result = {
units?: number[]
};

const UseProximityQuery = (params: SearchParams) => {
Expand Down Expand Up @@ -45,7 +45,7 @@ const UseProximityQuery = (params: SearchParams) => {
return null;
}

ids = locationsData.results.map((result: { unit: Unit }) => result.unit.id);
ids = locationsData.results.flatMap((result: Result) => result.units ?? []);
}

return fetch(`${baseUrl}/${index}/_search`, {
Expand Down

0 comments on commit 714b430

Please sign in to comment.