aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/api/resource/StatisticsResource.java14
-rw-r--r--src/main/java/org/traccar/database/DataManager.java8
2 files changed, 10 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/api/resource/StatisticsResource.java b/src/main/java/org/traccar/api/resource/StatisticsResource.java
index 5c0734877..1f2296f28 100644
--- a/src/main/java/org/traccar/api/resource/StatisticsResource.java
+++ b/src/main/java/org/traccar/api/resource/StatisticsResource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,13 @@
*/
package org.traccar.api.resource;
-import org.traccar.Context;
import org.traccar.api.BaseResource;
import org.traccar.model.Statistics;
import org.traccar.storage.StorageException;
+import org.traccar.storage.query.Columns;
+import org.traccar.storage.query.Condition;
+import org.traccar.storage.query.Order;
+import org.traccar.storage.query.Request;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -37,8 +40,11 @@ public class StatisticsResource extends BaseResource {
@GET
public Collection<Statistics> get(
@QueryParam("from") Date from, @QueryParam("to") Date to) throws StorageException {
- Context.getPermissionsManager().checkAdmin(getUserId());
- return Context.getDataManager().getStatistics(from, to);
+ permissionsService.checkAdmin(getUserId());
+ return storage.getObjects(Statistics.class, new Request(
+ new Columns.All(),
+ new Condition.Between("captureTime", "from", from, "to", to),
+ new Order("captureTime")));
}
}
diff --git a/src/main/java/org/traccar/database/DataManager.java b/src/main/java/org/traccar/database/DataManager.java
index 4fd0cd8c1..8ed907fdd 100644
--- a/src/main/java/org/traccar/database/DataManager.java
+++ b/src/main/java/org/traccar/database/DataManager.java
@@ -34,7 +34,6 @@ import org.traccar.model.Device;
import org.traccar.model.Permission;
import org.traccar.model.Position;
import org.traccar.model.Server;
-import org.traccar.model.Statistics;
import org.traccar.model.User;
import org.traccar.storage.DatabaseStorage;
import org.traccar.storage.Storage;
@@ -204,13 +203,6 @@ public class DataManager {
return storage.getObject(Server.class, new Request(new Columns.All()));
}
- public Collection<Statistics> getStatistics(Date from, Date to) throws StorageException {
- return storage.getObjects(Statistics.class, new Request(
- new Columns.All(),
- new Condition.Between("captureTime", "from", from, "to", to),
- new Order("captureTime")));
- }
-
public Collection<Permission> getPermissions(Class<? extends BaseModel> owner, Class<? extends BaseModel> property)
throws StorageException, ClassNotFoundException {
return storage.getPermissions(owner, property);