diff options
author | Julian <julian.toelle97@gmail.com> | 2019-01-06 20:29:05 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-01-06 21:29:05 +0200 |
commit | c42bde719ecf2dd8757453bed18e082d14c1d3fa (patch) | |
tree | bd8df8d22d5d8a884a004f8def30142ee134fbe1 | |
parent | 97dafdc0578ad24a14370c813c95108c0c41fc5b (diff) | |
download | gitea-c42bde719ecf2dd8757453bed18e082d14c1d3fa.tar.gz gitea-c42bde719ecf2dd8757453bed18e082d14c1d3fa.zip |
Only count users own actions for heatmap contributions (#5647)
Signed-off-by: Julian Tölle <julian.toelle97@gmail.com>
-rw-r--r-- | models/user_heatmap.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/models/user_heatmap.go b/models/user_heatmap.go index 0745a66058..3fdabbbf79 100644 --- a/models/user_heatmap.go +++ b/models/user_heatmap.go @@ -32,12 +32,22 @@ func GetUserHeatmapDataByUser(user *User) ([]*UserHeatmapData, error) { groupByName = groupBy } - err := x.Select(groupBy+" AS timestamp, count(user_id) as contributions"). + sess := x.Select(groupBy+" AS timestamp, count(user_id) as contributions"). Table("action"). Where("user_id = ?", user.ID). - And("created_unix > ?", (util.TimeStampNow() - 31536000)). - GroupBy(groupByName). + And("created_unix > ?", (util.TimeStampNow() - 31536000)) + + // * Heatmaps for individual users only include actions that the user themself + // did. + // * For organizations actions by all users that were made in owned + // repositories are counted. + if user.Type == UserTypeIndividual { + sess = sess.And("act_user_id = ?", user.ID) + } + + err := sess.GroupBy(groupByName). OrderBy("timestamp"). Find(&hdata) + return hdata, err } |