File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -549,6 +549,8 @@ export type TasksQuery = {
549549 afterFinishedAt ?: Date ;
550550 limit ?: number ;
551551 from ?: number ;
552+ /** If true, the tasks are returned in reverse order */
553+ reverse ?: boolean ;
552554} ;
553555
554556export type CancelTasksQuery = Omit < TasksQuery , "limit" | "from" > & { } ;
Original file line number Diff line number Diff line change @@ -369,6 +369,23 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
369369 ) ;
370370 } ) ;
371371
372+ test ( `${ permission } key: Get all tasks in reverse order` , async ( ) => {
373+ const currentTimeStamp = Date . now ( ) ;
374+ const currentTime = new Date ( currentTimeStamp ) ;
375+
376+ const client = await getClient ( permission ) ;
377+ const taskA = await client . index ( index . uid ) . addDocuments ( [ { id : 1 } ] ) ;
378+ const taskB = await client . index ( index . uid ) . addDocuments ( [ { id : 2 } ] ) ;
379+
380+ await client . waitForTask ( taskA . taskUid ) ;
381+ await client . waitForTask ( taskB . taskUid ) ;
382+
383+ const tasks = await client . getTasks ( { afterEnqueuedAt : currentTime } ) ;
384+ const reversedTasks = await client . getTasks ( { afterEnqueuedAt : currentTime , reverse : true } ) ;
385+ expect ( tasks . results . map ( ( t ) => t . uid ) ) . toEqual ( [ taskB . taskUid , taskA . taskUid ] ) ;
386+ expect ( reversedTasks . results . map ( ( t ) => t . uid ) ) . toEqual ( [ taskA . taskUid , taskB . taskUid ] ) ;
387+ } ) ;
388+
372389 // filters error code: INVALID_TASK_TYPES_FILTER
373390 test ( `${ permission } key: Try to filter on task types with wrong type` , async ( ) => {
374391 const client = await getClient ( permission ) ;
You can’t perform that action at this time.
0 commit comments