fix: Resolve duplicated display of users on online/offline dashboard
parent
4edddd2dbb
commit
5bfaa7f733
|
@ -66,7 +66,7 @@ export const reportUserService = async (req: Request, res: Response): Promise<Re
|
||||||
|
|
||||||
// let usersProfile = await ListUserParamiterService({ profile: 'user' })
|
// let usersProfile = await ListUserParamiterService({ profile: 'user' })
|
||||||
let usersProfile = await ListUserParamiterService({
|
let usersProfile = await ListUserParamiterService({
|
||||||
profile: "user",
|
profiles: ["user", "supervisor"],
|
||||||
raw: true
|
raw: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,17 @@ import { Op, Sequelize } from "sequelize";
|
||||||
import Queue from "../../models/Queue";
|
import Queue from "../../models/Queue";
|
||||||
import User from "../../models/User";
|
import User from "../../models/User";
|
||||||
import UserQueue from "../../models/UserQueue";
|
import UserQueue from "../../models/UserQueue";
|
||||||
|
import { List } from "whatsapp-web.js"
|
||||||
|
|
||||||
interface Request {
|
interface Request {
|
||||||
userId?: string | number;
|
userId?: string | number;
|
||||||
profile?: string;
|
profile?: string;
|
||||||
|
profiles?: Array<string>;
|
||||||
raw?: boolean;
|
raw?: boolean;
|
||||||
userIds?: string | number
|
userIds?: string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ListUser = async ({ profile, userId, raw, userIds }: Request): Promise<User[]> => {
|
const ListUser = async ({ profile, userId, raw, userIds, profiles }: Request): Promise<User[]> => {
|
||||||
let where_clause = {};
|
let where_clause = {};
|
||||||
|
|
||||||
if (userId && profile) {
|
if (userId && profile) {
|
||||||
|
@ -29,6 +31,10 @@ const ListUser = async ({ profile, userId, raw, userIds }: Request): Promise<Use
|
||||||
where_clause = {
|
where_clause = {
|
||||||
id: { [Op.in]: userIds }
|
id: { [Op.in]: userIds }
|
||||||
};
|
};
|
||||||
|
} else if (profiles) {
|
||||||
|
where_clause = {
|
||||||
|
profile: { [Op.in]: profiles }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const users = await User.findAll({
|
const users = await User.findAll({
|
||||||
|
@ -38,9 +44,10 @@ const ListUser = async ({ profile, userId, raw, userIds }: Request): Promise<Use
|
||||||
|
|
||||||
include: [
|
include: [
|
||||||
{ model: Queue, as: "queues", attributes: ["id", "name", "color"] }
|
{ model: Queue, as: "queues", attributes: ["id", "name", "color"] }
|
||||||
],
|
],
|
||||||
|
|
||||||
order: [["id", "ASC"]]
|
order: [["id", "ASC"]],
|
||||||
|
group: ["User.id"]
|
||||||
});
|
});
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
|
|
Loading…
Reference in New Issue