rez_core 5.0.7 → 5.0.9
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.
package/package.json
CHANGED
|
@@ -279,129 +279,115 @@ export class TaskService extends EntityServiceImpl {
|
|
|
279
279
|
const { mapped_entity_type, mapped_entity_id, status, mandatory, overdue } =
|
|
280
280
|
data;
|
|
281
281
|
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
|
|
282
|
+
const whereClauses: string[] = [];
|
|
283
|
+
const params: any[] = [];
|
|
284
|
+
let idx = 1;
|
|
285
285
|
|
|
286
|
+
// Required conditions
|
|
287
|
+
whereClauses.push(`t.mapped_entity_type = $${idx++}`);
|
|
288
|
+
params.push(mapped_entity_type);
|
|
289
|
+
|
|
290
|
+
whereClauses.push(`t.mapped_entity_id = $${idx++}`);
|
|
291
|
+
params.push(Number(mapped_entity_id));
|
|
292
|
+
|
|
293
|
+
// Optional filters
|
|
286
294
|
if (status) {
|
|
287
|
-
whereClauses.push(`t.status =
|
|
288
|
-
params.push(status);
|
|
295
|
+
whereClauses.push(`t.status = $${idx++}`);
|
|
296
|
+
params.push(Number(status));
|
|
289
297
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
298
|
+
|
|
299
|
+
if (mandatory !== undefined) {
|
|
300
|
+
whereClauses.push(`t.is_mandatory = $${idx++}`);
|
|
301
|
+
params.push(mandatory ? true : false);
|
|
293
302
|
}
|
|
303
|
+
|
|
294
304
|
if (overdue) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
305
|
+
// Use PostgreSQL CURRENT_DATE + CURRENT_TIME
|
|
306
|
+
whereClauses.push(`
|
|
307
|
+
(
|
|
308
|
+
t.due_date < CURRENT_DATE
|
|
309
|
+
OR (t.due_date = CURRENT_DATE AND t.due_time < CURRENT_TIME)
|
|
310
|
+
)
|
|
311
|
+
`);
|
|
312
|
+
|
|
313
|
+
// Only if not done
|
|
314
|
+
whereClauses.push(`t.is_done = $${idx++}`);
|
|
315
|
+
params.push(false);
|
|
301
316
|
}
|
|
302
317
|
|
|
303
318
|
const sql = `
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
319
|
+
SELECT
|
|
320
|
+
t.*,
|
|
321
|
+
sg.name AS stage_group_name,
|
|
322
|
+
s.name AS stage_name,
|
|
323
|
+
a.name AS action_name
|
|
324
|
+
FROM frm_wf_task_data t
|
|
325
|
+
LEFT JOIN frm_wf_stage s ON t.stage_id = s.id
|
|
326
|
+
LEFT JOIN frm_wf_stage_group sg ON s.stage_group_id = sg.id
|
|
327
|
+
LEFT JOIN frm_wf_action a ON t.action_id = a.id
|
|
328
|
+
WHERE ${whereClauses.join(" AND ")}
|
|
329
|
+
ORDER BY t.created_date DESC
|
|
330
|
+
`;
|
|
316
331
|
|
|
317
332
|
const taskData = await this.dataSource.query(sql, params);
|
|
318
333
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
334
|
+
// ------------------------------------------------------
|
|
335
|
+
// Resolve user profile
|
|
336
|
+
// ------------------------------------------------------
|
|
337
|
+
if (taskData?.length) {
|
|
338
|
+
for (const task of taskData) {
|
|
322
339
|
try {
|
|
323
|
-
const baseUrl = this.configService.get<string>(
|
|
340
|
+
const baseUrl = this.configService.get<string>("REDIRECT_BE_URL");
|
|
324
341
|
|
|
325
|
-
// Prepare the query string
|
|
326
342
|
const queryParams = new URLSearchParams({
|
|
327
343
|
loggedInUser: JSON.stringify(loggedInUser),
|
|
328
344
|
}).toString();
|
|
329
345
|
|
|
330
|
-
// Make the GET request with query parameters
|
|
331
346
|
const response = await axios.get(
|
|
332
|
-
`${baseUrl}/users/profile-image-url/${
|
|
333
|
-
{
|
|
334
|
-
headers: {
|
|
335
|
-
'Content-Type': 'application/json',
|
|
336
|
-
},
|
|
337
|
-
},
|
|
347
|
+
`${baseUrl}/users/profile-image-url/${task?.task_owner}?entity_type=USR&${queryParams}`,
|
|
348
|
+
{ headers: { "Content-Type": "application/json" } },
|
|
338
349
|
);
|
|
339
350
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
console.error('⚠️ Internal Entity API call failed:', error.message);
|
|
351
|
+
task.created_by_name = response.data.name;
|
|
352
|
+
task.task_owner_name = response.data.name;
|
|
353
|
+
task.task_owner_profile = response.data.profile_image;
|
|
354
|
+
} catch (err) {
|
|
355
|
+
console.error("⚠ Error fetching profile:", err.message);
|
|
346
356
|
}
|
|
347
357
|
}
|
|
348
358
|
}
|
|
349
359
|
|
|
350
|
-
if (taskData.length
|
|
351
|
-
return [];
|
|
352
|
-
}
|
|
360
|
+
if (!taskData.length) return [];
|
|
353
361
|
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
+
// ------------------------------------------------------
|
|
363
|
+
// Load All TKST Statuses
|
|
364
|
+
// ------------------------------------------------------
|
|
365
|
+
const statusSql = `
|
|
366
|
+
SELECT id, name
|
|
367
|
+
FROM frm_list_master_items
|
|
368
|
+
WHERE organization_id = $1
|
|
369
|
+
AND listtype = 'TKST'
|
|
370
|
+
`;
|
|
371
|
+
|
|
372
|
+
const allStatuses = await this.dataSource.query(statusSql, [
|
|
362
373
|
loggedInUser.organization_id,
|
|
363
374
|
]);
|
|
364
375
|
|
|
365
|
-
// Build a hash map { id → name }
|
|
366
376
|
const statusMap = new Map(
|
|
367
|
-
|
|
377
|
+
allStatuses.map((row) => [String(row.id), row.name]),
|
|
368
378
|
);
|
|
369
379
|
|
|
370
|
-
//
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
for (const task of taskData) {
|
|
375
|
-
// Map status name
|
|
376
|
-
task.task_status = task.status
|
|
377
|
-
? statusMap.get(String(task.status)) || null
|
|
378
|
-
: null;
|
|
379
|
-
|
|
380
|
-
// Fix action_name for generic tasks
|
|
381
|
-
task.action_name =
|
|
382
|
-
task.action_id === '0' || task.action_id === 0
|
|
383
|
-
? 'Generic'
|
|
384
|
-
: task.action_name;
|
|
385
|
-
|
|
386
|
-
// Profile media (with caching like notes)
|
|
387
|
-
// if (task.task_owner_profile) {
|
|
388
|
-
// if (!mediaCache.has(task.task_owner_profile)) {
|
|
389
|
-
// const url = await this.mediaDataService.getMediaDownloadUrl(
|
|
390
|
-
// Number(task.task_owner_profile),
|
|
391
|
-
// loggedInUser,
|
|
392
|
-
// );
|
|
393
|
-
// mediaCache.set(task.task_owner_profile, url);
|
|
394
|
-
// }
|
|
395
|
-
// task.task_owner_profile = mediaCache.get(task.task_owner_profile);
|
|
396
|
-
// } else {
|
|
397
|
-
// task.task_owner_profile = null;
|
|
398
|
-
// }
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// Normalize is_mandatory to '0'/'1' as string
|
|
380
|
+
// ------------------------------------------------------
|
|
381
|
+
// Normalize & decorate tasks
|
|
382
|
+
// ------------------------------------------------------
|
|
402
383
|
return taskData.map((task) => ({
|
|
403
384
|
...task,
|
|
404
|
-
|
|
385
|
+
task_status: statusMap.get(String(task.status)) || null,
|
|
386
|
+
action_name:
|
|
387
|
+
task.action_id === 0 || task.action_id === "0"
|
|
388
|
+
? "Generic"
|
|
389
|
+
: task.action_name,
|
|
390
|
+
is_mandatory: task.is_mandatory ? "1" : "0",
|
|
405
391
|
}));
|
|
406
392
|
}
|
|
407
393
|
|