Refactoring of sorting and filtering in API.
This commit is contained in:
parent
3590ba048d
commit
975d5288a3
6 changed files with 140 additions and 91 deletions
server/resources
|
@ -8,6 +8,7 @@ import {getTasks, Task, TaskState} from "../jobs/scheduler";
|
|||
import {normalizeString} from "../utils/strings";
|
||||
import {forConstraint} from "../validation/validator";
|
||||
import {Request, Response} from "express";
|
||||
import {isTaskSortField} from "../types";
|
||||
|
||||
const isValidId = forConstraint(CONSTRAINTS.id, false);
|
||||
|
||||
|
@ -81,7 +82,7 @@ async function doGetAll(req: Request): Promise<{total: number, pageTasks: Entity
|
|||
|
||||
const tasks = Resources.sort(
|
||||
_.values(getTasks()),
|
||||
['id', 'name', 'schedule', 'state', 'runningSince', 'lastRunStarted'],
|
||||
isTaskSortField,
|
||||
restParams
|
||||
);
|
||||
const filteredTasks = Resources.filter(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue