Skip to content

Commit

Permalink
Merge pull request #98 from usdot-jpo-ode/count-fixes
Browse files Browse the repository at this point in the history
Count fixes
  • Loading branch information
John-Wiens authored Jun 20, 2024
2 parents c36cb9c + 997e057 commit f417877
Show file tree
Hide file tree
Showing 69 changed files with 520 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public interface ConnectionOfTravelAssessmentRepository extends DataLoader<Conne
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<ConnectionOfTravelAssessment> find(Query query);


}

Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,20 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
return query;
}


public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, ConnectionOfTravelAssessment.class, collectionName);
}

// Removes the result limit on a count query.
public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, ConnectionOfTravelAssessment.class, collectionName);
query.limit(limit);
return count;
}

public List<ConnectionOfTravelAssessment> find(Query query) {
return mongoTemplate.find(query, ConnectionOfTravelAssessment.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public interface LaneDirectionOfTravelAssessmentRepository extends DataLoader<La
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<LaneDirectionOfTravelAssessment> find(Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import us.dot.its.jpo.conflictmonitor.monitor.models.assessments.LaneDirectionOfTravelAssessment;
import us.dot.its.jpo.ode.api.ConflictMonitorApiProperties;

Expand Down Expand Up @@ -51,14 +52,24 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}else{
query.limit(props.getMaximumResponseSize());
}

return query;
}



public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, LaneDirectionOfTravelAssessment.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, LaneDirectionOfTravelAssessment.class, collectionName);
query.limit(limit);
return count;
}

public List<LaneDirectionOfTravelAssessment> find(Query query) {
return mongoTemplate.find(query, LaneDirectionOfTravelAssessment.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public interface StopLineStopAssessmentRepository extends DataLoader<StopLineSto
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<StopLineStopAssessment> find(Query query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import us.dot.its.jpo.conflictmonitor.monitor.models.assessments.StopLineStopAssessment;
import us.dot.its.jpo.ode.api.ConflictMonitorApiProperties;

Expand Down Expand Up @@ -52,10 +53,17 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, StopLineStopAssessment.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, StopLineStopAssessment.class, collectionName);
query.limit(limit);
return count;
}

public List<StopLineStopAssessment> find(Query query) {
return mongoTemplate.find(query, StopLineStopAssessment.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public interface SignalStateEventAssessmentRepository extends DataLoader<StopLin

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<StopLinePassageAssessment> find(Query query);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, StopLinePassageAssessment.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, StopLinePassageAssessment.class, collectionName);
query.limit(limit);
return count;
}

public List<StopLinePassageAssessment> find(Query query) {
return mongoTemplate.find(query, StopLinePassageAssessment.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public interface BsmEventRepository extends DataLoader<BsmEvent>{
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<BsmEvent> find(Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,17 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, BsmEvent.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, BsmEvent.class, collectionName);
query.limit(limit);
return count;
}

public List<BsmEvent> find(Query query) {

List<Map> documents = mongoTemplate.find(query, Map.class, collectionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface ConnectionOfTravelEventRepository extends DataLoader<Connection
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<ConnectionOfTravelEvent> find(Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import us.dot.its.jpo.conflictmonitor.monitor.models.events.ConnectionOfTravelEvent;
import org.springframework.data.domain.Sort;

Expand Down Expand Up @@ -59,10 +60,17 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, ConnectionOfTravelEvent.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, ConnectionOfTravelEvent.class, collectionName);
query.limit(limit);
return count;
}

public List<ConnectionOfTravelEvent> find(Query query) {
return mongoTemplate.find(query, ConnectionOfTravelEvent.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public interface IntersectionReferenceAlignmentEventRepository extends DataLoade
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<IntersectionReferenceAlignmentEvent> find(Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import us.dot.its.jpo.conflictmonitor.monitor.models.events.IntersectionReferenceAlignmentEvent;
import us.dot.its.jpo.ode.api.ConflictMonitorApiProperties;
import us.dot.its.jpo.ode.api.models.IDCount;
Expand Down Expand Up @@ -58,11 +59,18 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, IntersectionReferenceAlignmentEvent.class,
collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, IntersectionReferenceAlignmentEvent.class, collectionName);
query.limit(limit);
return count;
}

public List<IntersectionReferenceAlignmentEvent> find(Query query) {
return mongoTemplate.find(query, IntersectionReferenceAlignmentEvent.class,
collectionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface LaneDirectionOfTravelEventRepository extends DataLoader<LaneDir

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<LaneDirectionOfTravelEvent> find(Query query);

List<IDCount> getLaneDirectionOfTravelEventsByDay(int intersectionID, Long startTime, Long endTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, LaneDirectionOfTravelEvent.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, LaneDirectionOfTravelEvent.class, collectionName);
query.limit(limit);
return count;
}

public List<LaneDirectionOfTravelEvent> find(Query query) {
return mongoTemplate.find(query, LaneDirectionOfTravelEvent.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public interface MapBroadcastRateEventRepository extends DataLoader<MapBroadcast
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<MapBroadcastRateEvent> find(Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, MapBroadcastRateEvent.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, MapBroadcastRateEvent.class, collectionName);
query.limit(limit);
return count;
}

public List<MapBroadcastRateEvent> find(Query query) {
return mongoTemplate.find(query, MapBroadcastRateEvent.class, collectionName);
}
Expand Down Expand Up @@ -91,6 +98,8 @@ public List<IDCount> getMapBroadcastRateEventsByDay(int intersectionID, Long sta
return results;
}



@Override
public void add(MapBroadcastRateEvent item) {
mongoTemplate.save(item, collectionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public interface MapMinimumDataEventRepository extends DataLoader<MapMinimumData
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<MapMinimumDataEvent> find(Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, MapMinimumDataEvent.class, collectionName);
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, MapMinimumDataEvent.class, collectionName);
query.limit(limit);
return count;
}

public List<MapMinimumDataEvent> find(Query query) {
return mongoTemplate.find(query, MapMinimumDataEvent.class, collectionName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public interface SignalGroupAlignmentEventRepository extends DataLoader<SignalGr
Query getQuery(Integer intersectionID, Long startTime, Long endTime, boolean latest);

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<SignalGroupAlignmentEvent> find(Query query);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import us.dot.its.jpo.conflictmonitor.monitor.models.events.SignalGroupAlignmentEvent;

import org.springframework.data.domain.Sort;

import org.springframework.data.mongodb.core.aggregation.Aggregation;
Expand Down Expand Up @@ -59,10 +60,17 @@ public Query getQuery(Integer intersectionID, Long startTime, Long endTime, bool
}

public long getQueryResultCount(Query query) {
query.limit(-1);
return mongoTemplate.count(query, SignalGroupAlignmentEvent.class, "CmSignalGroupAlignmentEvents");
}

public long getQueryFullCount(Query query){
int limit = query.getLimit();
query.limit(-1);
long count = mongoTemplate.count(query, SignalGroupAlignmentEvent.class, collectionName);
query.limit(limit);
return count;
}

public List<SignalGroupAlignmentEvent> find(Query query) {
return mongoTemplate.find(query, SignalGroupAlignmentEvent.class, "CmSignalGroupAlignmentEvents");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface SignalStateConflictEventRepository extends DataLoader<SignalSta

long getQueryResultCount(Query query);

long getQueryFullCount(Query query);

List<SignalStateConflictEvent> find(Query query);

List<IDCount> getSignalStateConflictEventsByDay(int intersectionID, Long startTime, Long endTime);
Expand Down
Loading

0 comments on commit f417877

Please sign in to comment.