From c1400a2226b7b33c5a2a77ee1545e4e45e171dd7 Mon Sep 17 00:00:00 2001 From: kittapath Date: Thu, 27 Feb 2025 17:11:18 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=81=E0=B8=A9=E0=B8=B2=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80?= =?UTF-8?q?=E0=B8=AD=E0=B8=B23=E0=B8=AD=E0=B8=B1=E0=B8=99=E0=B8=94?= =?UTF-8?q?=E0=B8=B1=E0=B8=9A=E0=B9=81=E0=B8=A3=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index a90492dc..7d926453 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -7087,9 +7087,10 @@ export class OrganizationController extends Controller { (x) => x.orgChild1Id == null && // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgRoot.orgRootShortName + x.posMasterNo, @@ -7134,9 +7135,10 @@ export class OrganizationController extends Controller { (x) => x.orgChild2Id == null && // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgChild1.orgChild1ShortName + x.posMasterNo, @@ -7189,9 +7191,10 @@ export class OrganizationController extends Controller { (x) => x.orgChild3Id == null && // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgChild2.orgChild2ShortName + x.posMasterNo, @@ -7251,9 +7254,10 @@ export class OrganizationController extends Controller { (x) => x.orgChild4Id == null && // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgChild3.orgChild3ShortName + x.posMasterNo, @@ -7319,8 +7323,10 @@ export class OrganizationController extends Controller { .filter( (x) => // x.current_holderId != null && - x.posMasterOrder <= 3 && x.isDirector === true, + x.isDirector === true, ) + .sort((a, b) => a.posMasterOrder - b.posMasterOrder) // Sort by posMasterOrder ASC + .slice(0, 3) // Select the first 3 rows .map(async (x) => ({ posmasterId: x.id, posNo: orgChild4.orgChild4ShortName + x.posMasterNo,