fixed performance function GetOfficersByAdminRoleV3
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s
This commit is contained in:
parent
362515a7ca
commit
0ba5e36a4f
1 changed files with 53 additions and 32 deletions
|
|
@ -8593,13 +8593,29 @@ export class OrganizationDotnetController extends Controller {
|
|||
where: {
|
||||
...typeCondition,
|
||||
createdAt: LessThanOrEqual(date),
|
||||
// firstName: Not("") && Not(IsNull()),
|
||||
// lastName: Not("") && Not(IsNull()),
|
||||
},
|
||||
select: [
|
||||
"profileId",
|
||||
"prefix",
|
||||
"firstName",
|
||||
"lastName",
|
||||
"shortName",
|
||||
"posMasterNo",
|
||||
"position",
|
||||
"posType",
|
||||
"posLevel",
|
||||
"ancestorDNA",
|
||||
"rootDnaId",
|
||||
"child1DnaId",
|
||||
"child2DnaId",
|
||||
"child3DnaId",
|
||||
"child4DnaId",
|
||||
"createdAt",
|
||||
],
|
||||
order: {
|
||||
firstName: "ASC",
|
||||
lastName: "ASC",
|
||||
createdAt: "DESC", // ให้ createdAt ล่าสุดอยู่ข้างบน
|
||||
createdAt: "DESC",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -8646,36 +8662,41 @@ export class OrganizationDotnetController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
const profile_ = await Promise.all(
|
||||
Array.from(grouped3.values())
|
||||
.filter((x) => x.profileId != null)
|
||||
.map(async (item: PosMasterHistory) => {
|
||||
let profile = await this.profileRepo.findOne({
|
||||
where: { id: item.profileId },
|
||||
});
|
||||
const profileIds = Array.from(grouped3.values())
|
||||
.filter((x) => x.profileId != null)
|
||||
.map((x) => x.profileId);
|
||||
|
||||
return {
|
||||
id: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: profile?.citizenId ?? null,
|
||||
dateStart: profile?.dateStart ?? null,
|
||||
dateAppoint: profile?.dateAppoint ?? null,
|
||||
keycloak: profile?.keycloak ?? null,
|
||||
posNo: `${item.shortName} ${item.posMasterNo}`,
|
||||
position: item.position,
|
||||
positionLevel: item.posLevel,
|
||||
positionType: item.posType,
|
||||
// oc: Oc,
|
||||
orgRootId: item.rootDnaId,
|
||||
orgChild1Id: item.child1DnaId,
|
||||
orgChild2Id: item.child2DnaId,
|
||||
orgChild3Id: item.child3DnaId,
|
||||
orgChild4Id: item.child4DnaId,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const profiles = await this.profileRepo.find({
|
||||
where: { id: In(profileIds) },
|
||||
select: ["id", "citizenId", "dateStart", "dateAppoint", "keycloak"],
|
||||
});
|
||||
|
||||
const profileMap = new Map(profiles.map((p) => [p.id, p]));
|
||||
|
||||
const profile_ = Array.from(grouped3.values())
|
||||
.filter((x) => x.profileId != null)
|
||||
.map((item: PosMasterHistory) => {
|
||||
const profile = profileMap.get(item.profileId);
|
||||
return {
|
||||
id: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: profile?.citizenId ?? null,
|
||||
dateStart: profile?.dateStart ?? null,
|
||||
dateAppoint: profile?.dateAppoint ?? null,
|
||||
keycloak: profile?.keycloak ?? null,
|
||||
posNo: `${item.shortName} ${item.posMasterNo}`,
|
||||
position: item.position,
|
||||
positionLevel: item.posLevel,
|
||||
positionType: item.posType,
|
||||
orgRootId: item.rootDnaId,
|
||||
orgChild1Id: item.child1DnaId,
|
||||
orgChild2Id: item.child2DnaId,
|
||||
orgChild3Id: item.child3DnaId,
|
||||
orgChild4Id: item.child4DnaId,
|
||||
};
|
||||
});
|
||||
|
||||
return new HttpSuccess(
|
||||
(profile_ ?? []).sort((a, b) => a.posNo.localeCompare(b.posNo, undefined, { numeric: true })),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue