Skip to content

Commit 0514702

Browse files
committed
enh: improve db pink line node handling and submission features
- Added feature_type "pink_line_node" to createPinkLineNode and updated submission logic to include this type. - Refactored type definitions to accommodate the new feature type in various functions. - Improved filtering logic for pink line routes in submission batch summaries.
1 parent c469f50 commit 0514702

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/supabase/pinkLine.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export async function createPinkLineNode(
2929
geom: pointGeoJSON,
3030
project_id: projectId,
3131
submission_id: null,
32+
feature_type: "pink_line_node",
3233
},
3334
])
3435
.select("id")
@@ -104,7 +105,7 @@ export async function submitPinkLineRoute(
104105

105106
const { error } = await supabase
106107
.from("geo_features")
107-
.update({ submission_id: submissionId })
108+
.update({ submission_id: submissionId, feature_type: "pink_line_node" })
108109
.in("id", nodeIds)
109110
.eq("project_id", projectId);
110111

src/supabase/submissionBatches.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ type SubmissionBatchRow = SubmissionBatchListRow & {
5757
type GeoFeatureCountRow = {
5858
submission_id: string;
5959
project_id: string;
60-
feature_type: MemorialFeatureType | null;
60+
feature_type: string | null;
6161
};
6262

63+
function isLegacyOrTaggedPinkNode(featureType: string | null): boolean {
64+
return featureType === null || featureType === "pink_line_node";
65+
}
66+
6367
/** PostgREST default row cap; paginate reads to avoid truncated lists and wrong counts. */
6468
const GEO_FEATURES_PAGE_SIZE = 1000;
6569

@@ -152,6 +156,7 @@ export async function listSubmissionBatchSummariesForMapContext(
152156
if (!bucket) continue;
153157

154158
if (pinkProjectId && r.project_id === pinkProjectId) {
159+
if (r.feature_type === "pink_line_route") continue;
155160
bucket.pinkNodeCount += 1;
156161
} else if (memorialProjectId && r.project_id === memorialProjectId) {
157162
if (r.feature_type === "central") bucket.memorialCentralCount += 1;
@@ -232,6 +237,7 @@ export async function listSubmissionBatchSummariesForWorkspace(
232237
if (!bucket) continue;
233238

234239
if (pinkProjectId && r.project_id === pinkProjectId) {
240+
if (r.feature_type === "pink_line_route") continue;
235241
bucket.pinkNodeCount += 1;
236242
} else if (memorialProjectId && r.project_id === memorialProjectId) {
237243
if (r.feature_type === "central") bucket.memorialCentralCount += 1;
@@ -287,7 +293,7 @@ export async function loadSubmissionBatchMapDetail(
287293
description: string | null;
288294
geom: unknown;
289295
project_id: string;
290-
feature_type: MemorialFeatureType | null;
296+
feature_type: string | null;
291297
created_at: string | null;
292298
};
293299

@@ -312,6 +318,7 @@ export async function loadSubmissionBatchMapDetail(
312318
const tempId = `gf-${row.id}`;
313319

314320
if (pinkProjectId && row.project_id === pinkProjectId) {
321+
if (!isLegacyOrTaggedPinkNode(row.feature_type)) continue;
315322
pinkNodes.push({
316323
tempId,
317324
name: row.name,

src/supabase/unifiedSubmission.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ function buildGeoFeatureRows(
7676
name: string;
7777
description: string;
7878
geom: GeoJSON;
79-
feature_type?: MemorialFeatureType;
79+
feature_type?: MemorialFeatureType | "pink_line_node";
8080
}> {
8181
const rows: Array<{
8282
project_id: string;
8383
submission_id: string;
8484
name: string;
8585
description: string;
8686
geom: GeoJSON;
87-
feature_type?: MemorialFeatureType;
87+
feature_type?: MemorialFeatureType | "pink_line_node";
8888
}> = [];
8989

9090
if (params.includePink) {
@@ -99,6 +99,7 @@ function buildGeoFeatureRows(
9999
name: node.name?.trim() || "Pink Line Node",
100100
description: node.description?.trim() || "",
101101
geom: { type: "Point", coordinates: [node.lng, node.lat] } as GeoJSON,
102+
feature_type: "pink_line_node" as const,
102103
}))
103104
);
104105
}
@@ -131,7 +132,7 @@ function rowsToRpcPayload(
131132
description: string;
132133
lng: number;
133134
lat: number;
134-
feature_type: MemorialFeatureType | null;
135+
feature_type: MemorialFeatureType | "pink_line_node" | null;
135136
}> {
136137
return rows.map((r) => {
137138
const g = r.geom as GeoJSON.Point;

0 commit comments

Comments
 (0)