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

nodes db: return an empty data field for the geojson collection #1169

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ describe(`${objectName}`, () => {
expect(collection[1].properties.id).toBe(_newObjectAttributes2.id);
expect(collection[1].properties).toMatchObject(_newObjectAttributes2);

// data fields should be empty, but present
expect(collection[0].properties.data).toEqual({});
expect(collection[1].properties.data).toEqual({});

});

test('should read a subset geojson collection from database', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const geojsonCollection = async (
// TODO: we should not fetch the whole data content, we should read node when modifying one instead of creating a Node from the geojson
try {
const { nodeIds } = params;
// FIXME: The data field is mandatory, so we initialize it with an empty object. It should not be mandatory in the first place.
const innerQuery = knex(tableName)
.select(
'id',
Expand All @@ -92,6 +93,7 @@ const geojsonCollection = async (
'is_frozen', is_frozen,
'code', code,
'name', name,
'data', '{}'::jsonb,
'description', description,
'geography', ST_AsGeoJSON(geography)::jsonb,
'is_enabled', is_enabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,10 @@ export class TransitAccessibilityMapResultByNode {
continue;
}

// FIXME node's 'data' field is not accessible in the frontend
// anymore, at least when retrieved from the node collection, so
// this feature will not work anymore as long as it is calculated in
// the frontend
const nodeAccessiblePlacesByCategory =
nodeAttributes.data?.accessiblePlaces?.walking?.placesByTravelTimeByCategory; // TODO: allow stats for other modes
nodeAttributes.data.accessiblePlaces?.walking?.placesByTravelTimeByCategory; // TODO: allow stats for other modes
const nodeAccessiblePlacesByDetailedCategory =
nodeAttributes.data?.accessiblePlaces?.walking?.placesByTravelTimeByDetailedCategory;
nodeAttributes.data.accessiblePlaces?.walking?.placesByTravelTimeByDetailedCategory;
for (let timeMinutes = avgRemainingTimeMinutes; timeMinutes >= 0; timeMinutes--) {
if (nodeAccessiblePlacesByCategory) {
const accessiblePlacesForTravelTimeByCategory = nodeAccessiblePlacesByCategory[timeMinutes];
Expand Down
Loading