Skip to content

Commit

Permalink
handle features/feature data link via stable ids through piece export…
Browse files Browse the repository at this point in the history
…ers/importers
  • Loading branch information
hotzevzl committed Feb 23, 2024
1 parent 4ccf078 commit 4682dba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ProjectCustomFeaturesSelectResult = {
alias: string;
description: string;
property_name: string;
feature_data_ids: string[];
intersection: string[];
creation_status: CreationStatus;
list_property_keys: string[];
Expand All @@ -38,6 +39,7 @@ type ProjectCustomFeaturesSelectResult = {

type FeaturesDataSelectResult = {
feature_id: string;
stable_id: string;
the_geom: string;
properties: Record<string, string | number>;
source: GeometrySource;
Expand Down Expand Up @@ -80,6 +82,7 @@ export class ProjectCustomFeaturesPieceExporter
'f.description',
'f.property_name',
'f.intersection',
'f.feature_data_stable_ids',
'f.creation_status',
'f.list_property_keys',
'f.is_legacy',
Expand All @@ -100,6 +103,7 @@ export class ProjectCustomFeaturesPieceExporter
.createQueryBuilder()
.select([
'feature_id',
'stable_id',
'the_geom',
'properties',
'source',
Expand All @@ -120,7 +124,7 @@ export class ProjectCustomFeaturesPieceExporter
...feature,
data: customFeaturesData
.filter((data) => data.feature_id === id)
.map(({ feature_id, project_pu_id, ...data }) => {
.map(({ feature_id: _feature_id, project_pu_id, ...data }) => {
const puid = project_pu_id
? projectPusMap[project_pu_id]
: undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ProjectCustomFeaturesPieceImporter
const featureIdByClassName: Record<string, string> = {};
const featureInsertValues: any[] = [];
const featureTagInsertValues: any[] = [];
features.forEach(({ data, tag, ...feature }) => {
features.forEach(({ data: _data, tag, ...feature }) => {
const featureId = v4();
featureIdByClassName[feature.feature_class_name] = featureId;

Expand Down Expand Up @@ -139,6 +139,7 @@ export class ProjectCustomFeaturesPieceImporter
theGeom: () => `'${data.the_geom}'`,
properties: data.properties,
source: data.source,
stableId: data.stable_id,
featureId: featureIdByClassName[feature_class_name],
amount: data.amount,
projectPuId: projectPuPuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum JobStatus {

type FeatureData = {
the_geom: string;
stable_id: string;
properties: Record<string, string | number>;
source: GeometrySource;
amount: number | null;
Expand All @@ -27,6 +28,7 @@ export type ProjectCustomFeature = {
description: string;
property_name: string;
intersection: string[];
feature_data_stable_ids: string[];
creation_status: JobStatus;
list_property_keys: string[];
is_legacy: boolean;
Expand Down

0 comments on commit 4682dba

Please sign in to comment.