fix: api /super-admin/{id} memory cache
This commit is contained in:
parent
7c70229579
commit
1a324af483
5 changed files with 112 additions and 2 deletions
|
|
@ -51,6 +51,7 @@ import {
|
|||
CreatePosMasterHistoryEmployee,
|
||||
CreatePosMasterHistoryOfficer,
|
||||
} from "../services/PositionService";
|
||||
import { orgStructureCache } from "../utils/OrgStructureCache";
|
||||
|
||||
@Route("api/v1/org")
|
||||
@Tags("Organization")
|
||||
|
|
@ -1196,6 +1197,12 @@ export class OrganizationController extends Controller {
|
|||
rootId = posMaster.orgRootId;
|
||||
}
|
||||
|
||||
// OPTIMIZED: Check cache first
|
||||
const cachedResponse = await orgStructureCache.get(id, rootId);
|
||||
if (cachedResponse) {
|
||||
return new HttpSuccess(cachedResponse);
|
||||
}
|
||||
|
||||
// OPTIMIZED: Get all position counts in ONE query (closed)
|
||||
// const { orgRootMap, orgChild1Map, orgChild2Map, orgChild3Map, orgChild4Map, rootPosMap } =
|
||||
// await getPositionCounts(id);
|
||||
|
|
@ -1527,6 +1534,9 @@ export class OrganizationController extends Controller {
|
|||
};
|
||||
});
|
||||
|
||||
// OPTIMIZED: Cache the result
|
||||
await orgStructureCache.set(id, rootId, formattedData);
|
||||
|
||||
return new HttpSuccess(formattedData);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue