@peopl-health/nexus 5.46.0-dev.7269 → 5.46.0-dev.7270
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.
|
@@ -31,9 +31,8 @@ const codesOf = (row) => (Array.isArray(row.whatsapp_id) ? row.whatsapp_id : [ro
|
|
|
31
31
|
.filter(Boolean);
|
|
32
32
|
|
|
33
33
|
const addTask = (summary, code, kind, isUrgent, createdAt) => {
|
|
34
|
-
const entry = summary.get(code) || { requests: 0, cases: 0,
|
|
34
|
+
const entry = summary.get(code) || { requests: 0, cases: 0, isUrgent: false, oldestAt: null };
|
|
35
35
|
entry[kind] += 1;
|
|
36
|
-
entry.count += 1;
|
|
37
36
|
entry.isUrgent = entry.isUrgent || isUrgent;
|
|
38
37
|
if (createdAt && (!entry.oldestAt || createdAt < entry.oldestAt)) entry.oldestAt = createdAt;
|
|
39
38
|
summary.set(code, entry);
|
|
@@ -67,14 +66,19 @@ async function getOpenTaskSummary() {
|
|
|
67
66
|
if (cached) return cached;
|
|
68
67
|
if (!inFlight) {
|
|
69
68
|
const loadGeneration = generation;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (
|
|
69
|
+
const load = loadSummary().then(
|
|
70
|
+
(summary) => {
|
|
71
|
+
if (inFlight === load) inFlight = null;
|
|
72
|
+
if (loadGeneration !== generation) return getOpenTaskSummary();
|
|
73
|
+
cache.set(CACHE_KEY, summary);
|
|
73
74
|
return summary;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
inFlight = null;
|
|
77
|
-
|
|
75
|
+
},
|
|
76
|
+
(error) => {
|
|
77
|
+
if (inFlight === load) inFlight = null;
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
inFlight = load;
|
|
78
82
|
}
|
|
79
83
|
return inFlight;
|
|
80
84
|
}
|