@peopl-health/nexus 5.48.0-dev.7383 → 5.48.0-dev.7386
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.
|
@@ -140,15 +140,20 @@ const taskFilter = (kind, whatsappId) => {
|
|
|
140
140
|
|
|
141
141
|
const byOpenThenNewest = (a, b) => (b.isOpen - a.isOpen) || (b.createdAt || '').localeCompare(a.createdAt || '');
|
|
142
142
|
|
|
143
|
+
const needsUrgentAttention = (task) => task.needsAttention && task.isUrgent;
|
|
144
|
+
|
|
143
145
|
async function readTasks(kind, whatsappId) {
|
|
144
146
|
const { table, fields, toTask } = TASK_KINDS[kind];
|
|
145
147
|
const rows = await getRecordByFilter(Monitoreo_ID, table, taskFilter(kind, whatsappId), null, fields, true);
|
|
146
148
|
const tasks = rows.map(toTask).sort(byOpenThenNewest);
|
|
149
|
+
const capped = [...tasks.filter(needsUrgentAttention), ...tasks.filter((task) => !needsUrgentAttention(task))]
|
|
150
|
+
.slice(0, MAX_ROWS)
|
|
151
|
+
.sort(byOpenThenNewest);
|
|
147
152
|
return {
|
|
148
|
-
tasks:
|
|
153
|
+
tasks: capped,
|
|
149
154
|
openCount: tasks.filter((task) => task.isOpen).length,
|
|
150
155
|
attentionCount: tasks.filter((task) => task.needsAttention).length,
|
|
151
|
-
isUrgent: tasks.some(
|
|
156
|
+
isUrgent: tasks.some(needsUrgentAttention),
|
|
152
157
|
};
|
|
153
158
|
}
|
|
154
159
|
|