@things-factory/operato-wms 4.3.756 → 4.3.757
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.outboundOrderByStatusResolver = void 0;
|
|
4
4
|
const biz_base_1 = require("@things-factory/biz-base");
|
|
5
|
+
// Simple in-memory cache with 30 second TTL
|
|
6
|
+
const dashboardCache = new Map();
|
|
7
|
+
// Auto-cleanup expired cache entries every 5 minutes
|
|
8
|
+
setInterval(() => {
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
for (const [key, value] of dashboardCache.entries()) {
|
|
11
|
+
if (value.expires <= now) {
|
|
12
|
+
dashboardCache.delete(key);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}, 5 * 60 * 1000);
|
|
5
16
|
exports.outboundOrderByStatusResolver = {
|
|
6
17
|
async outboundOrderByStatus(_, params, context) {
|
|
7
18
|
var _a;
|
|
@@ -14,8 +25,22 @@ exports.outboundOrderByStatusResolver = {
|
|
|
14
25
|
}
|
|
15
26
|
else
|
|
16
27
|
throw new Error('invalid bizplaceId');
|
|
28
|
+
// Create cache key from domain and sorted bizplace IDs
|
|
29
|
+
const cacheKey = `${domain.id}:${bizplaceIds.sort().join(',')}`;
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
// Check cache first
|
|
32
|
+
const cached = dashboardCache.get(cacheKey);
|
|
33
|
+
if (cached && cached.expires > now) {
|
|
34
|
+
return cached.data;
|
|
35
|
+
}
|
|
36
|
+
// Cache miss - query database
|
|
17
37
|
let items = await tx.query(`Select * from dashboard($1,$2) `, [bizplaceIds, domain.id]);
|
|
18
38
|
const orderStatus = items;
|
|
39
|
+
// Store in cache for 30 seconds
|
|
40
|
+
dashboardCache.set(cacheKey, {
|
|
41
|
+
data: orderStatus,
|
|
42
|
+
expires: now + 30000
|
|
43
|
+
});
|
|
19
44
|
return orderStatus;
|
|
20
45
|
}
|
|
21
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outbound-order-by-status.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/dashboard/outbound-order-by-status.ts"],"names":[],"mappings":";;;AAIA,uDAAkE;
|
|
1
|
+
{"version":3,"file":"outbound-order-by-status.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/dashboard/outbound-order-by-status.ts"],"names":[],"mappings":";;;AAIA,uDAAkE;AAElE,4CAA4C;AAC5C,MAAM,cAAc,GAAG,IAAI,GAAG,EAA0C,CAAA;AAExE,qDAAqD;AACrD,WAAW,CAAC,GAAG,EAAE;IACf,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IACtB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,cAAc,CAAC,OAAO,EAAE,EAAE;QACnD,IAAI,KAAK,CAAC,OAAO,IAAI,GAAG,EAAE;YACxB,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;SAC3B;KACF;AACH,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;AAEJ,QAAA,6BAA6B,GAAG;IAC3C,KAAK,CAAC,qBAAqB,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;;QACjE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAsD,OAAO,CAAC,KAAK,CAAA;QAC7F,MAAM,UAAU,GAAW,CAAA,MAAA,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,0CAAE,KAAK,KAAI,KAAK,CAAA;QAC3G,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,wEAAwE,CAAC,CAAA;QAC/F,IAAI,WAAW,GAAa,EAAE,CAAA;QAE9B,IAAI,UAAU,IAAI,CAAC,UAAU,IAAI,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE;YAC/D,WAAW,GAAG,UAAU,IAAI,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,kCAAuB,EAAC,MAAM,EAAE,IAAI,CAAC,CAAA;SAC7G;;YAAM,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;QAE5C,uDAAuD;QACvD,MAAM,QAAQ,GAAG,GAAG,MAAM,CAAC,EAAE,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAEtB,oBAAoB;QACpB,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC3C,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,GAAG,GAAG,EAAE;YAClC,OAAO,MAAM,CAAC,IAAI,CAAA;SACnB;QAED,8BAA8B;QAC9B,IAAI,KAAK,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,iCAAiC,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;QAEvF,MAAM,WAAW,GAAwC,KAAK,CAAA;QAE9D,gCAAgC;QAChC,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC3B,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,GAAG,GAAG,KAAK;SACrB,CAAC,CAAA;QAEF,OAAO,WAAW,CAAA;IACpB,CAAC;CACF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-wms",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.757",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"cypress-localstorage-commands": "^1.6.1",
|
|
118
118
|
"eslint-plugin-cypress": "^2.12.1"
|
|
119
119
|
},
|
|
120
|
-
"gitHead": "
|
|
120
|
+
"gitHead": "790920bb75d34b837c589f30b7a3d992e44753a1"
|
|
121
121
|
}
|
|
@@ -4,6 +4,19 @@ import { User } from '@things-factory/auth-base'
|
|
|
4
4
|
import { Domain, ListParam } from '@things-factory/shell'
|
|
5
5
|
import { getPermittedBizplaceIds } from '@things-factory/biz-base'
|
|
6
6
|
|
|
7
|
+
// Simple in-memory cache with 30 second TTL
|
|
8
|
+
const dashboardCache = new Map<string, { data: any; expires: number }>()
|
|
9
|
+
|
|
10
|
+
// Auto-cleanup expired cache entries every 5 minutes
|
|
11
|
+
setInterval(() => {
|
|
12
|
+
const now = Date.now()
|
|
13
|
+
for (const [key, value] of dashboardCache.entries()) {
|
|
14
|
+
if (value.expires <= now) {
|
|
15
|
+
dashboardCache.delete(key)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}, 5 * 60 * 1000)
|
|
19
|
+
|
|
7
20
|
export const outboundOrderByStatusResolver = {
|
|
8
21
|
async outboundOrderByStatus(_: any, params: ListParam, context: any) {
|
|
9
22
|
const { domain, user, tx }: { domain: Domain; user: User; tx: EntityManager } = context.state
|
|
@@ -15,10 +28,27 @@ export const outboundOrderByStatusResolver = {
|
|
|
15
28
|
bizplaceIds = bizplaceId && bizplaceId != 'ALL' ? [bizplaceId] : await getPermittedBizplaceIds(domain, user)
|
|
16
29
|
} else throw new Error('invalid bizplaceId')
|
|
17
30
|
|
|
31
|
+
// Create cache key from domain and sorted bizplace IDs
|
|
32
|
+
const cacheKey = `${domain.id}:${bizplaceIds.sort().join(',')}`
|
|
33
|
+
const now = Date.now()
|
|
34
|
+
|
|
35
|
+
// Check cache first
|
|
36
|
+
const cached = dashboardCache.get(cacheKey)
|
|
37
|
+
if (cached && cached.expires > now) {
|
|
38
|
+
return cached.data
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Cache miss - query database
|
|
18
42
|
let items = await tx.query(`Select * from dashboard($1,$2) `, [bizplaceIds, domain.id])
|
|
19
43
|
|
|
20
44
|
const orderStatus: { status: string; count: number }[] = items
|
|
21
45
|
|
|
46
|
+
// Store in cache for 30 seconds
|
|
47
|
+
dashboardCache.set(cacheKey, {
|
|
48
|
+
data: orderStatus,
|
|
49
|
+
expires: now + 30000
|
|
50
|
+
})
|
|
51
|
+
|
|
22
52
|
return orderStatus
|
|
23
53
|
}
|
|
24
54
|
}
|