Skip to content

Commit

Permalink
fix: correct findMediaByAreaId() call signature (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
vnugent committed Jun 5, 2024
1 parent a9ae822 commit df91b92
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/db/utils/jobs/MapTiles/exportCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -72,8 +85,8 @@ async function exportLeafCrags (): Promise<void> {
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,
Expand Down Expand Up @@ -169,7 +182,8 @@ async function exportAreas (): Promise<void> {
metadata: {
isDestination: 1,
polygon: 1,
leftRightIndex: 1
leftRightIndex: 1,
level: { $size: { $split: ['$ancestors', ','] } }
},
pathTokens: 1,
ancestors: { $split: ['$ancestors', ','] },
Expand All @@ -192,19 +206,7 @@ async function exportAreas (): Promise<void> {
{
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
},
{
Expand Down

0 comments on commit df91b92

Please sign in to comment.