Skip to content

Commit

Permalink
revert changes to accessor count aggregations
Browse files Browse the repository at this point in the history
  • Loading branch information
linda-baker committed Dec 14, 2024
1 parent 1f62273 commit bd4edcc
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,17 @@ public List<IDCount> getMapBroadcastRateEventsByDay(int intersectionID, Long sta
Date endTimeDate = new Date();

if (startTime != null) {
startTime = 0L;

startTimeDate = new Date(startTime);
}
if (endTime != null) {
endTime = System.currentTimeMillis();
endTimeDate = new Date(endTime);
}

Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("intersectionID").is(intersectionID)),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTime).lte(endTime)),
Aggregation.project()
.andExpression("{$toDate: '$eventGeneratedAt'}").as("eventGeneratedAtDate"),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTimeDate).lte(endTimeDate)),
Aggregation.project()
.andExpression("{$dateToString: { format: '%Y-%m-%d', date: '$eventGeneratedAtDate' }}").as("dateStr"),
.and(DateOperators.DateToString.dateOf("eventGeneratedAt").toString("%Y-%m-%d")).as("dateStr"),
Aggregation.group("dateStr").count().as("count")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,22 @@ public List<MapMinimumDataEvent> find(Query query) {
return mongoTemplate.find(query, MapMinimumDataEvent.class, collectionName);
}

public List<IDCount> getMapMinimumDataEventsByDay(int intersectionID, Long startTime, Long endTime) {
if (startTime == null) {
startTime = 0L;
public List<IDCount> getMapMinimumDataEventsByDay(int intersectionID, Long startTime, Long endTime){
Date startTimeDate = new Date(0);
Date endTimeDate = new Date();

if (startTime != null) {
startTimeDate = new Date(startTime);
}
if (endTime == null) {
endTime = System.currentTimeMillis();
if (endTime != null) {
endTimeDate = new Date(endTime);
}

Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("intersectionID").is(intersectionID)),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTime).lte(endTime)),
Aggregation.project()
.andExpression("{$toDate: '$eventGeneratedAt'}").as("eventGeneratedAtDate"),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTimeDate).lte(endTimeDate)),
Aggregation.project()
.andExpression("{$dateToString: { format: '%Y-%m-%d', date: '$eventGeneratedAtDate' }}").as("dateStr"),
.and(DateOperators.DateToString.dateOf("eventGeneratedAt").toString("%Y-%m-%d")).as("dateStr"),
Aggregation.group("dateStr").count().as("count")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,25 @@ public List<SignalStateConflictEvent> find(Query query) {
return mongoTemplate.find(query, SignalStateConflictEvent.class, collectionName);
}

public List<IDCount> getSignalStateConflictEventsByDay(int intersectionID, Long startTime, Long endTime) {
if (startTime == null) {
startTime = 0L;
public List<IDCount> getSignalStateConflictEventsByDay(int intersectionID, Long startTime, Long endTime){
Date startTimeDate = new Date(0);
Date endTimeDate = new Date();

if (startTime != null) {
startTimeDate = new Date(startTime);
}
if (endTime == null) {
endTime = System.currentTimeMillis();
if (endTime != null) {
endTimeDate = new Date(endTime);
}

Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("intersectionID").is(intersectionID)),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTime).lte(endTime)),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTimeDate).lte(endTimeDate)),
Aggregation.project()
.andExpression("{$toDate: '$eventGeneratedAt'}").as("eventGeneratedAtDate"),
Aggregation.project()
.andExpression("{$dateToString: { format: '%Y-%m-%d', date: '$eventGeneratedAtDate' }}").as("dateStr"),
.and(DateOperators.DateToString.dateOf("eventGeneratedAt").toString("%Y-%m-%d")).as("dateStr"),
Aggregation.group("dateStr").count().as("count")
);

AggregationResults<IDCount> result = mongoTemplate.aggregate(aggregation, collectionName, IDCount.class);
List<IDCount> results = result.getMappedResults();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,22 @@ public List<SpatBroadcastRateEvent> find(Query query) {
return mongoTemplate.find(query, SpatBroadcastRateEvent.class, collectionName);
}

public List<IDCount> getSpatBroadcastRateEventsByDay(int intersectionID, Long startTime, Long endTime) {
if (startTime == null) {
startTime = 0L;
public List<IDCount> getSpatBroadcastRateEventsByDay(int intersectionID, Long startTime, Long endTime){
Date startTimeDate = new Date(0);
Date endTimeDate = new Date();

if (startTime != null) {
startTimeDate = new Date(startTime);
}
if (endTime == null) {
endTime = System.currentTimeMillis();
if (endTime != null) {
endTimeDate = new Date(endTime);
}

Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("intersectionID").is(intersectionID)),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTime).lte(endTime)),
Aggregation.project()
.andExpression("{$toDate: '$eventGeneratedAt'}").as("eventGeneratedAtDate"),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTimeDate).lte(endTimeDate)),
Aggregation.project()
.andExpression("{$dateToString: { format: '%Y-%m-%d', date: '$eventGeneratedAtDate' }}").as("dateStr"),
.and(DateOperators.DateToString.dateOf("eventGeneratedAt").toString("%Y-%m-%d")).as("dateStr"),
Aggregation.group("dateStr").count().as("count")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,22 @@ public List<SpatMinimumDataEvent> find(Query query) {
return mongoTemplate.find(query, SpatMinimumDataEvent.class, collectionName);
}

public List<IDCount> getSpatMinimumDataEventsByDay(int intersectionID, Long startTime, Long endTime) {
if (startTime == null) {
startTime = 0L;
public List<IDCount> getSpatMinimumDataEventsByDay(int intersectionID, Long startTime, Long endTime){
Date startTimeDate = new Date(0);
Date endTimeDate = new Date();

if (startTime != null) {
startTimeDate = new Date(startTime);
}
if (endTime == null) {
endTime = System.currentTimeMillis();
if (endTime != null) {
endTimeDate = new Date(endTime);
}

Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("intersectionID").is(intersectionID)),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTime).lte(endTime)),
Aggregation.project()
.andExpression("{$toDate: '$eventGeneratedAt'}").as("eventGeneratedAtDate"),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTimeDate).lte(endTimeDate)),
Aggregation.project()
.andExpression("{$dateToString: { format: '%Y-%m-%d', date: '$eventGeneratedAtDate' }}").as("dateStr"),
.and(DateOperators.DateToString.dateOf("eventGeneratedAt").toString("%Y-%m-%d")).as("dateStr"),
Aggregation.group("dateStr").count().as("count")
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,22 @@ public List<TimeChangeDetailsEvent> find(Query query) {
return mongoTemplate.find(query, TimeChangeDetailsEvent.class, collectionName);
}

public List<IDCount> getTimeChangeDetailsEventsByDay(int intersectionID, Long startTime, Long endTime) {
if (startTime == null) {
startTime = 0L;
public List<IDCount> getTimeChangeDetailsEventsByDay(int intersectionID, Long startTime, Long endTime){
Date startTimeDate = new Date(0);
Date endTimeDate = new Date();

if (startTime != null) {
startTimeDate = new Date(startTime);
}
if (endTime == null) {
endTime = System.currentTimeMillis();
if (endTime != null) {
endTimeDate = new Date(endTime);
}

Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("intersectionID").is(intersectionID)),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTime).lte(endTime)),
Aggregation.project()
.andExpression("{$toDate: '$eventGeneratedAt'}").as("eventGeneratedAtDate"),
Aggregation.match(Criteria.where("eventGeneratedAt").gte(startTimeDate).lte(endTimeDate)),
Aggregation.project()
.andExpression("{$dateToString: { format: '%Y-%m-%d', date: '$eventGeneratedAtDate' }}").as("dateStr"),
.and(DateOperators.DateToString.dateOf("eventGeneratedAt").toString("%Y-%m-%d")).as("dateStr"),
Aggregation.group("dateStr").count().as("count")
);

Expand Down

0 comments on commit bd4edcc

Please sign in to comment.