sort and filter by GPSFIX.TIME_AS_MILLIS, not only TIME_AS_MILLIS; it is an internal field

Change-Id: Iafbb59da918a7bd8650f61567e01b64bbce27660
This commit is contained in:
Axel Uhl committed 2017-07-31 23:55:23 +02:00
1 parent 6d95ad2353
commit c847350a12
1 file changed
+4 -4
@@ -129,17 +129,17 @@ public class MongoSensorFixStoreImpl implements MongoSensorFixStore {
DBObject dbDeviceId = storeDeviceId(deviceServiceFinder, device);
final QueryBuilder queryBuilder = QueryBuilder.start(FieldNames.DEVICE_ID.name()).is(dbDeviceId)
.and(FieldNames.TIME_AS_MILLIS.name());
.and(FieldNames.GPSFIX.name()+"."+FieldNames.TIME_AS_MILLIS.name());
if (inclusive) {
queryBuilder.greaterThanEquals(loadFixesFrom.asMillis()).and(FieldNames.TIME_AS_MILLIS.name())
queryBuilder.greaterThanEquals(loadFixesFrom.asMillis()).and(FieldNames.GPSFIX.name()+"."+FieldNames.TIME_AS_MILLIS.name())
.lessThanEquals(loadFixesTo.asMillis());
} else {
queryBuilder.greaterThanEquals(loadFixesFrom.asMillis()).and(FieldNames.TIME_AS_MILLIS.name())
queryBuilder.greaterThanEquals(loadFixesFrom.asMillis()).and(FieldNames.GPSFIX.name()+"."+FieldNames.TIME_AS_MILLIS.name())
.lessThan(loadFixesTo.asMillis());
}
DBObject query = queryBuilder.get();
DBCursor result = fixesCollection.find(query);
result.sort(new BasicDBObject(FieldNames.TIME_AS_MILLIS.name(), ascending ? 1 : -1));
result.sort(new BasicDBObject(FieldNames.GPSFIX.name()+"."+FieldNames.TIME_AS_MILLIS.name(), ascending ? 1 : -1));
if (onlyOneResult) {
result.limit(1);
}