Skip to content

Commit d39d807

Browse files
committed
sorting fix
1 parent bd648c5 commit d39d807

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

source/api/v1/api/handlers/notes/NotesHandlers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export class NotesHandler implements Handler {
5252
extractToken(request)
5353
)
5454

55-
const {limit, offset, date_sort, tags} = request.query
55+
const {limit, offset, sort: date_sort, tags} = request.query
5656

57-
const notes = await this.notesService.getMyNotes(login, {tags, limit, offset, date_sort})
57+
const notes = await this.notesService.getMyNotes(login, {tags, limit, offset, sort: date_sort})
5858
if (isException(notes)) {
5959
reply.code(notes.statusCode).send(notes)
6060
return
@@ -74,9 +74,9 @@ export class NotesHandler implements Handler {
7474
extractToken(request)
7575
)
7676

77-
const {limit, offset, date_sort, tags} = request.query
77+
const {limit, offset, sort: date_sort, tags} = request.query
7878

79-
const notes = await this.notesService.getCollaboratedNotes(login, {tags, limit, offset, date_sort})
79+
const notes = await this.notesService.getCollaboratedNotes(login, {tags, limit, offset, sort: date_sort})
8080
if (isException(notes)) {
8181
reply.code(notes.statusCode).send(notes)
8282
return

source/api/v1/api/validation/schemas/NoteSchemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const GetNotesSchema: FastifySchema = {
3232
properties: {
3333
limit: { type: 'integer', minimum: 0 },
3434
offset: { type: 'integer', minimum: 0 },
35-
date_sort: { type: "string", enum: ["ASC", "DESC"] },
35+
sort: { type: "string", enum: ["ASC", "DESC"] },
3636
tags: { type: 'array', items: { type: 'string' }, maxItems: 20 }
3737
}
3838
},

source/api/v1/services/notes/NotesService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export class NotesService implements INotesService {
180180
.where("note.author = :login", {login: authorLogin})
181181
.limit(options?.limit)
182182
.skip(options?.offset)
183-
.orderBy("note.updatedAt", options?.date_sort);
183+
.orderBy("note.updatedAt", options?.sort);
184184

185185
const tags = options?.tags;
186186
if (tags && tags.length) {
@@ -213,7 +213,7 @@ export class NotesService implements INotesService {
213213
])
214214
.limit(options?.limit)
215215
.skip(options?.offset)
216-
.orderBy("note.updatedAt", options?.date_sort);
216+
.orderBy("note.updatedAt", options?.sort);
217217

218218
const tags = options?.tags;
219219
if (tags && tags.length) {

source/api/v1/services/notes/NotesServiceInterface.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export type NotesSearchOptions = DeepOptional<{
77
tags: string[]
88
limit: number
99
offset: number
10-
date_sort: "ASC" | "DESC"
10+
sort: "ASC" | "DESC"
1111
}>
1212

1313
export interface INotesService {

0 commit comments

Comments
 (0)