@spytecgps/nova-orm 1.0.4 → 1.0.5
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,9 @@ import { DeviceTask, TaskSchedule } from '../../entities';
|
|
|
2
2
|
import { anyAttributeHasValue } from '../../utils/anyAttributeHasValue';
|
|
3
3
|
import { addFilters, getTaskSchedulesFilterMapping } from '../../utils/filterTools';
|
|
4
4
|
const getDeviceTasksForTaskSchedules = async (taskSchedulesIds, numberOfDevicesToGet, dataSource) => {
|
|
5
|
+
if (!taskSchedulesIds.length) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
5
8
|
const result = taskSchedulesIds.map(id => ({
|
|
6
9
|
id,
|
|
7
10
|
deviceTasks: [],
|
|
@@ -62,7 +65,7 @@ export const getTaskSchedules = async (novaDataSource, params, logger) => {
|
|
|
62
65
|
.limit(params?.pagingOptions?.pageSize ?? 100)
|
|
63
66
|
.offset((params?.pagingOptions?.pageSize ?? 100) * (params?.pagingOptions?.pageIndex ?? 0))
|
|
64
67
|
.getMany();
|
|
65
|
-
if (params.projectionOptions?.numberOfDevicesToGet > 0) {
|
|
68
|
+
if (params.projectionOptions?.numberOfDevicesToGet > 0 && result?.length > 0) {
|
|
66
69
|
const items = await getDeviceTasksForTaskSchedules(result.map(taskSchedule => taskSchedule.id), params.projectionOptions.numberOfDevicesToGet, dataSource);
|
|
67
70
|
for (const taskSchedule of result) {
|
|
68
71
|
const filteredItems = items.filter(item => item.id === taskSchedule.id);
|