Skip to content

Commit e115b9e

Browse files
committed
feat: sort ticks by most recent
1 parent ef3a5ab commit e115b9e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/model/TickDataSource.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ export default class TickDataSource extends MongoDataSource<TickType> {
103103
throw new Error('No such user')
104104
}
105105
// Unfortunately, userIds on ticks are stored as strings not MUUIDs.
106-
return await this.tickModel.find({ userId: userIdObject._id.toUUID().toString() })
106+
return await this.tickModel
107+
.find({ userId: userIdObject._id.toUUID().toString() })
108+
.sort({ dateClimbed: -1 })
109+
.lean()
107110
}
108111

109112
/**
@@ -112,7 +115,10 @@ export default class TickDataSource extends MongoDataSource<TickType> {
112115
* @param climbId climb uuid
113116
*/
114117
async ticksByUserIdAndClimb (climbId: string, userId?: string): Promise<TickType[]> {
115-
return await this.tickModel.find({ ...(userId != null && { userId }), climbId }).sort({ dateClimbed: -1 }).lean()
118+
return await this.tickModel
119+
.find({ ...(userId != null && { userId }), climbId })
120+
.sort({ dateClimbed: -1 })
121+
.lean()
116122
}
117123

118124
static instance: TickDataSource

0 commit comments

Comments
 (0)