Skip to content

Commit

Permalink
Add tasks pagination and filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-stupakov committed Sep 19, 2023
1 parent 8f52c75 commit ebb46df
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions web-app/server/src/graphql/schema/UserResolvers/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AuthenticationError } from "apollo-server-express";
import { FindOptions, Op } from "sequelize";
import { Permission } from "../../../db/models/UserData/Permission";
import { Role } from "../../../db/models/UserData/Role";
import { TaskState } from "../../../db/models/TaskData/TaskState";
import config from "../../../config";
import { createAndSendVerificationCode } from "./emailSender";
import jwt from "jsonwebtoken";
Expand Down Expand Up @@ -57,14 +58,20 @@ export const UserResolvers: Resolvers = {
}
return await models.Feedback.findAll({ where: { userID } });
},
tasks: async ({ userID }, _, { models }) => {
tasks: async ({ userID }, { pagination, withDeleted }, { models }) => {
if (!userID) {
throw new ApolloError("UserID is undefined");
}

const configs = await models.GeneralTaskConfig.findAll({
where: { userID },
paranoid: true,
attributes: ["taskID", "fileID", ["type", "propertyPrefix"]],
where: { "$taskState.userID$": userID },
include: {
model: TaskState,
attributes: ["userID"],
},
paranoid: !withDeleted,
...pagination,
attributes: ["taskID", "fileID", ["type", "prefix"]],
});
return configs as (GeneralTaskConfig & {
prefix: MainPrimitiveType;
Expand Down

0 comments on commit ebb46df

Please sign in to comment.