From df91b92cfd89094adde79208ef4588f383f65dec Mon Sep 17 00:00:00 2001 From: Viet Nguyen <3805254+vnugent@users.noreply.github.com> Date: Wed, 5 Jun 2024 04:00:51 -0700 Subject: [PATCH] fix: correct findMediaByAreaId() call signature (#404) --- src/db/utils/jobs/MapTiles/exportCmd.ts | 34 +++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/db/utils/jobs/MapTiles/exportCmd.ts b/src/db/utils/jobs/MapTiles/exportCmd.ts index 6af22bf..cfa3288 100644 --- a/src/db/utils/jobs/MapTiles/exportCmd.ts +++ b/src/db/utils/jobs/MapTiles/exportCmd.ts @@ -24,6 +24,19 @@ import { ClimbType } from '../../../ClimbTypes.js' import MutableMediaDataSource from '../../../../model/MutableMediaDataSource.js' import { workingDir } from './init.js' +const MEDIA_PROJECTION = { + width: 1, + height: 1, + mediaUrl: 1, + format: 1, + _id: 0, + 'entityTags.targetId': 1, + 'entityTags.ancestors': 1, + 'entityTags.climbName': 1, + 'entityTags.areaName': 1, + 'entityTags.type': 1 +} + /** * Export leaf areas as Geojson. Leaf areas are crags/boulders that have climbs. */ @@ -72,8 +85,8 @@ async function exportLeafCrags (): Promise { content, media: await MutableMediaDataSource.getInstance().findMediaByAreaId( metadata.area_id, - ancestors - ), + MEDIA_PROJECTION, + true), climbs: climbs.map(({ _id, name, type, grades }: ClimbType) => ({ id: _id.toUUID().toString(), name, @@ -169,7 +182,8 @@ async function exportAreas (): Promise { metadata: { isDestination: 1, polygon: 1, - leftRightIndex: 1 + leftRightIndex: 1, + level: { $size: { $split: ['$ancestors', ','] } } }, pathTokens: 1, ancestors: { $split: ['$ancestors', ','] }, @@ -192,19 +206,7 @@ async function exportAreas (): Promise { { type: 'areas', ...doc, - media: await MutableMediaDataSource.getInstance().findMediaByAreaId(muuid.from(doc.id), { - width: 1, - height: 1, - mediaUrl: 1, - format: 1, - _id: 0, - 'entityTags.targetId': 1, - 'entityTags.ancestors': 1, - 'entityTags.climbName': 1, - 'entityTags.areaName': 1, - 'entityTags.type': 1 - }, - true), + media: await MutableMediaDataSource.getInstance().findMediaByAreaId(muuid.from(doc.id), MEDIA_PROJECTION, true), metadata: doc.metadata }, {