fix:首页日期选择器报错

fix:首页日期选择器报错
This commit is contained in:
lanyulei 2022-11-02 00:28:50 +08:00 committed by GitHub
commit 1de9c1fa5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -55,14 +55,19 @@ func (s *Statistics) DateRangeStatistics() (statisticsData map[string][]interfac
for i := 0; i < TimeDifference; i++ {
if i == 0 {
sqlDataValue += "SELECT curdate() AS click_date UNION ALL"
sqlDataValue += fmt.Sprintf("SELECT date_sub(date_format( '%s', '%%Y%%m%%d'), INTERVAL 0 DAY ) AS click_date UNION ALL", endTime)
} else if i == TimeDifference-1 {
sqlDataValue += fmt.Sprintf(` SELECT date_sub( curdate(), INTERVAL %d DAY ) AS click_date`, i)
sqlDataValue += fmt.Sprintf(` SELECT date_sub(date_format( '%s', '%%Y%%m%%d'), INTERVAL %d DAY ) AS click_date UNION ALL`, endTime, i)
sqlDataValue += fmt.Sprintf(` SELECT date_sub(date_format( '%s', '%%Y%%m%%d'), INTERVAL %d DAY ) AS click_date`, endTime, i + 1)
} else {
sqlDataValue += fmt.Sprintf(` SELECT date_sub( curdate(), INTERVAL %d DAY ) AS click_date UNION ALL`, i)
sqlDataValue += fmt.Sprintf(` SELECT date_sub(date_format( '%s', '%%Y%%m%%d'), INTERVAL %d DAY ) AS click_date UNION ALL`, endTime, i)
}
}
if TimeDifference == 1 {
sqlDataValue += fmt.Sprintf(" SELECT date_sub(date_format( '%s', '%%Y%%m%%d'), INTERVAL 1 DAY ) AS click_date",endTime)
}
sqlValue = fmt.Sprintf(`SELECT
a.click_date,
ifnull( b.total, 0 ) AS total,