-
-
Notifications
You must be signed in to change notification settings - Fork 41
Sort area children by leftRightIndex #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
e51db9e
127faf5
cc0e38d
666fa4c
38515ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| import { MUUID } from 'uuid-mongodb' | ||
| import { Point } from '@turf/helpers' | ||
| import { AreaType } from '../db/AreaTypes' | ||
| import { ClimbType } from '../db/ClimbTypes' | ||
|
|
||
| export const muuidToString = (m: MUUID): string => m.toUUID().toString() | ||
|
|
||
|
|
@@ -21,3 +23,17 @@ export function exhaustiveCheck (_value: never): never { | |
|
|
||
| export const geojsonPointToLongitude = (point: Point): number => point.coordinates[0] | ||
| export const geojsonPointToLatitude = (point: Point): number => point.coordinates[1] | ||
|
|
||
| export function compareAreaLeftRightIndex (a: AreaType, b: AreaType): number { | ||
|
||
| if (a.metadata.leftRightIndex == null || b.metadata.leftRightIndex == null) { | ||
| return 0 // Preserve order if any element is missing leftRightIndex | ||
| } | ||
| return (a.metadata.leftRightIndex - b.metadata.leftRightIndex) | ||
| } | ||
|
|
||
| export function compareClimbLeftRightIndex (a: ClimbType, b: ClimbType): number { | ||
| if (a.metadata.left_right_index == null || b.metadata.left_right_index == null) { | ||
| return 0 // Preserve order if any element is missing left_right_index | ||
| } | ||
| return (a.metadata.left_right_index - b.metadata.left_right_index) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think if we let Mongo handle the sorting here and in
findManyClimbsByUuids(). This way we don't have to write comparators.Something like:
edit: add lean()