mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-06-17 17:00:03 +02:00
fix: include activity needed for entire heatmap (#7893)
Problem: Only data from the past 365 days (31536000s) is loaded. However, on the activity heatmap, there are 53 cols, each is 7 rows, so squares for at most 371 days (32054400s) are on the heatmap. This results in a few blank squares on the very left side, despite activity. Solution: Simply changing 31536000s (365d) to 32054400s (371d) to load all the needed activity. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7893 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Granular9241 <granular9241@noreply.codeberg.org> Co-committed-by: Granular9241 <granular9241@noreply.codeberg.org>
This commit is contained in:
parent
d4cc593578
commit
ddbc24c46b
3 changed files with 19 additions and 1 deletions
|
@ -13,6 +13,12 @@ import (
|
|||
"forgejo.org/modules/timeutil"
|
||||
)
|
||||
|
||||
const (
|
||||
// contributionsMaxAgeSeconds How old data to retrieve for the heatmap.
|
||||
// 371 days to cover the entire heatmap (53 *full* weeks)
|
||||
contributionsMaxAgeSeconds = 32054400
|
||||
)
|
||||
|
||||
// UserHeatmapData represents the data needed to create a heatmap
|
||||
type UserHeatmapData struct {
|
||||
Timestamp timeutil.TimeStamp `json:"timestamp"`
|
||||
|
@ -62,7 +68,7 @@ func getUserHeatmapData(ctx context.Context, user *user_model.User, team *organi
|
|||
Select(groupBy+" AS timestamp, count(user_id) as contributions").
|
||||
Table("action").
|
||||
Where(cond).
|
||||
And("created_unix > ?", timeutil.TimeStampNow()-31536000).
|
||||
And("created_unix >= ?", timeutil.TimeStampNow()-contributionsMaxAgeSeconds).
|
||||
GroupBy("timestamp").
|
||||
OrderBy("timestamp").
|
||||
Find(&hdata)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue