Skip to content

Commit df91b92

Browse files
authored
fix: correct findMediaByAreaId() call signature (#404)
1 parent a9ae822 commit df91b92

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/db/utils/jobs/MapTiles/exportCmd.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ import { ClimbType } from '../../../ClimbTypes.js'
2424
import MutableMediaDataSource from '../../../../model/MutableMediaDataSource.js'
2525
import { workingDir } from './init.js'
2626

27+
const MEDIA_PROJECTION = {
28+
width: 1,
29+
height: 1,
30+
mediaUrl: 1,
31+
format: 1,
32+
_id: 0,
33+
'entityTags.targetId': 1,
34+
'entityTags.ancestors': 1,
35+
'entityTags.climbName': 1,
36+
'entityTags.areaName': 1,
37+
'entityTags.type': 1
38+
}
39+
2740
/**
2841
* Export leaf areas as Geojson. Leaf areas are crags/boulders that have climbs.
2942
*/
@@ -72,8 +85,8 @@ async function exportLeafCrags (): Promise<void> {
7285
content,
7386
media: await MutableMediaDataSource.getInstance().findMediaByAreaId(
7487
metadata.area_id,
75-
ancestors
76-
),
88+
MEDIA_PROJECTION,
89+
true),
7790
climbs: climbs.map(({ _id, name, type, grades }: ClimbType) => ({
7891
id: _id.toUUID().toString(),
7992
name,
@@ -169,7 +182,8 @@ async function exportAreas (): Promise<void> {
169182
metadata: {
170183
isDestination: 1,
171184
polygon: 1,
172-
leftRightIndex: 1
185+
leftRightIndex: 1,
186+
level: { $size: { $split: ['$ancestors', ','] } }
173187
},
174188
pathTokens: 1,
175189
ancestors: { $split: ['$ancestors', ','] },
@@ -192,19 +206,7 @@ async function exportAreas (): Promise<void> {
192206
{
193207
type: 'areas',
194208
...doc,
195-
media: await MutableMediaDataSource.getInstance().findMediaByAreaId(muuid.from(doc.id), {
196-
width: 1,
197-
height: 1,
198-
mediaUrl: 1,
199-
format: 1,
200-
_id: 0,
201-
'entityTags.targetId': 1,
202-
'entityTags.ancestors': 1,
203-
'entityTags.climbName': 1,
204-
'entityTags.areaName': 1,
205-
'entityTags.type': 1
206-
},
207-
true),
209+
media: await MutableMediaDataSource.getInstance().findMediaByAreaId(muuid.from(doc.id), MEDIA_PROJECTION, true),
208210
metadata: doc.metadata
209211
},
210212
{

0 commit comments

Comments
 (0)