diff options
author | kolaente <konrad@kola-entertainments.de> | 2018-11-01 19:12:17 +0100 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-11-01 14:12:17 -0400 |
commit | 225c48982b501597b2368b65400e6294eca3e261 (patch) | |
tree | 7dcc67144f747ac7c6ced6bd98333d33cab69bf0 /models | |
parent | fa165621ed8c94722652e76d6853d0a0a41bfc5e (diff) | |
download | gitea-225c48982b501597b2368b65400e6294eca3e261.tar.gz gitea-225c48982b501597b2368b65400e6294eca3e261.zip |
Fixed heatmap not working in mssql (#5248)
Diffstat (limited to 'models')
-rw-r--r-- | models/user_heatmap.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/models/user_heatmap.go b/models/user_heatmap.go index f9575ed50f..9e603f4fe1 100644 --- a/models/user_heatmap.go +++ b/models/user_heatmap.go @@ -19,6 +19,7 @@ type UserHeatmapData struct { func GetUserHeatmapDataByUser(user *User) ([]*UserHeatmapData, error) { hdata := make([]*UserHeatmapData, 0) var groupBy string + var groupByName = "timestamp" // We need this extra case because mssql doesn't allow grouping by alias switch { case setting.UseSQLite3: groupBy = "strftime('%s', strftime('%Y-%m-%d', created_unix, 'unixepoch'))" @@ -28,13 +29,14 @@ func GetUserHeatmapDataByUser(user *User) ([]*UserHeatmapData, error) { groupBy = "extract(epoch from date_trunc('day', to_timestamp(created_unix)))" case setting.UseMSSQL: groupBy = "dateadd(DAY,0, datediff(day,0, dateadd(s, created_unix, '19700101')))" + groupByName = groupBy } - err := x.Select(groupBy+" as timestamp, count(user_id) as contributions"). + err := x.Select(groupBy+" AS timestamp, count(user_id) as contributions"). Table("action"). Where("user_id = ?", user.ID). And("created_unix > ?", (util.TimeStampNow() - 31536000)). - GroupBy("timestamp"). + GroupBy(groupByName). OrderBy("timestamp"). Find(&hdata) return hdata, err |