Skip to content

Commit

Permalink
#2205 fixed data monitoring sql query mysql dedicated
Browse files Browse the repository at this point in the history
  • Loading branch information
ufoscw authored and kyungtaak committed Jun 12, 2019
1 parent 4798833 commit 2cd24cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,11 @@ public ResponseEntity<?> countByStatusDate(
LineChartSeriesResponse<DateTime> result = new LineChartSeriesResponse<>(seriesNames);

mapByDate.entrySet().forEach(map -> {
DateTime dateTime = new DateTime(map.getKey(), DateTimeZone.UTC)
.withTime(0, 0, 0, 0);
String yearAndDayOfYear = map.getKey();
DateTime dateTime
= new DateTime(Integer.parseInt(yearAndDayOfYear.substring(0, 4)), 1, 1, 0, 0, DateTimeZone.UTC)
.plusDays(Integer.parseInt(yearAndDayOfYear.substring(4)) - 1);

Map<Audit.AuditStatus, Long> cntMap = map.getValue();
result.add(dateTime, cntMap.get(Audit.AuditStatus.SUCCESS), cntMap.get(Audit.AuditStatus.FAIL));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ public List<AuditStatsDto> countByUser(Predicate predicate) {
public List<AuditStatsDto> countStatusByDate(Predicate predicate) {
NumberPath<Long> aliasDate = Expressions.numberPath(Long.class, "date");
QAudit qAudit = QAudit.audit;
Expression<String> groupDateExpr = qAudit.startTime.year().stringValue()
.concat(qAudit.startTime.dayOfYear().stringValue());

Expression<String> groupDateExpr = Expressions.stringTemplate("DATE_FORMAT({0}, {1})", qAudit.startTime, "%Y-%m-%d");
Expression<String> selectDateExpr = Expressions.stringTemplate("DATE_FORMAT({0}, {1})", qAudit.startTime, "%Y-%m-%d").as("date");
Expression<String> selectDateExpr = qAudit.startTime.year().stringValue()
.concat(qAudit.startTime.dayOfYear().stringValue())
.as("date");

return from(qAudit)
.select(Projections.constructor(AuditStatsDto.class, selectDateExpr, qAudit.status, qAudit.count()))
Expand Down

0 comments on commit 2cd24cc

Please sign in to comment.