aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/resource
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/api/resource')
-rw-r--r--src/main/java/org/traccar/api/resource/PositionResource.java14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/main/java/org/traccar/api/resource/PositionResource.java b/src/main/java/org/traccar/api/resource/PositionResource.java
index 099d97632..cac64feb1 100644
--- a/src/main/java/org/traccar/api/resource/PositionResource.java
+++ b/src/main/java/org/traccar/api/resource/PositionResource.java
@@ -17,10 +17,8 @@ package org.traccar.api.resource;
import org.traccar.api.BaseResource;
import org.traccar.helper.model.PositionUtil;
-import org.traccar.model.BaseModel;
import org.traccar.model.Device;
import org.traccar.model.Position;
-import org.traccar.model.User;
import org.traccar.model.UserRestrictions;
import org.traccar.storage.StorageException;
import org.traccar.storage.query.Columns;
@@ -37,7 +35,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
-import java.util.stream.Collectors;
@Path("positions")
@Produces(MediaType.APPLICATION_JSON)
@@ -68,16 +65,7 @@ public class PositionResource extends BaseResource {
new Columns.All(), new Condition.LatestPositions(deviceId)));
}
} else {
- var devices = storage.getObjects(Device.class, new Request(
- new Columns.Include("id"),
- new Condition.Permission(User.class, getUserId(), Device.class)));
- var deviceIds = devices.stream().map(BaseModel::getId).collect(Collectors.toUnmodifiableSet());
-
- var positions = storage.getObjects(Position.class, new Request(
- new Columns.All(), new Condition.LatestPositions()));
- return positions.stream()
- .filter(position -> deviceIds.contains(position.getDeviceId()))
- .collect(Collectors.toList());
+ return PositionUtil.getLatestPositions(storage, getUserId());
}
}