-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
User action heatmap #5131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
User action heatmap #5131
Changes from 18 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
26bb85f
Added basic heatmap data
kolaente f27fe68
Added extra case for sqlite
kolaente af87a62
Built basic heatmap into user profile
kolaente 562257c
Get contribution data from api & styling
kolaente 1a36952
Fixed lint & added extra group by statements for all database types
kolaente 1ae7ed2
generated swagger spec
kolaente 7823d45
generated swagger spec
kolaente 3f2562a
generated swagger spec
kolaente a1d3fb7
fixed swagger spec
kolaente 5d99fc5
fmt
kolaente 63cf602
Added tests
kolaente b01dcd2
Added setting to enable/disable user heatmap
kolaente cac8299
Added locale for loading text
kolaente a831999
Removed UseTiDB
kolaente 068eaaf
Merge branch 'master' into feature/commit-heatmap
kolaente fdd3132
Updated librejs & moment.js
kolaente dd04de8
Merge remote-tracking branch 'origin/feature/commit-heatmap' into fea…
kolaente 86aa012
Merge branch 'master' into feature/commit-heatmap
kolaente 8fb9857
Merge branch 'master' into feature/commit-heatmap
kolaente 3a85ca7
Fixed import order
kolaente bed8f3c
Merge remote-tracking branch 'origin/feature/commit-heatmap' into fea…
kolaente 6e9519f
Fixed heatmap in postgresql
kolaente 6d724e6
Update docs/content/doc/advanced/config-cheat-sheet.en-us.md
sapk 7ecaeac
Merge branch 'master' into feature/commit-heatmap
kolaente 9db3069
Added copyright header
kolaente 2ea5a1e
Fixed a bug to show the heatmap for the actual user instead of the cu…
kolaente 06846be
Added integration test for heatmaps
kolaente 20a35d6
Added a heatmap on the dashboard
kolaente 81d98ed
Fixed timestamp parsing
kolaente e441242
Merge branch 'master' into feature/commit-heatmap
kolaente 8de8db1
Hide heatmap on mobile
kolaente 9c0e184
optimized postgresql group by query
kolaente 727171a
Improved sqlite group by statement
kolaente e8a7559
Merge branch 'master' into feature/commit-heatmap
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
act_user_id: 2 | ||
repo_id: 2 | ||
is_private: true | ||
created_unix: 1540139562 | ||
|
||
- | ||
id: 2 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package models | ||
kolaente marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"code.gitea.io/gitea/modules/setting" | ||
"code.gitea.io/gitea/modules/util" | ||
) | ||
|
||
// UserHeatmapData represents the data needed to create a heatmap | ||
type UserHeatmapData struct { | ||
Timestamp util.TimeStamp `json:"timestamp"` | ||
Contributions int64 `json:"contributions"` | ||
} | ||
|
||
// GetUserHeatmapDataByUser returns an array of UserHeatmapData | ||
func GetUserHeatmapDataByUser(user *User) (hdata []*UserHeatmapData, err error) { | ||
|
||
var groupBy string | ||
switch { | ||
case setting.UseSQLite3: | ||
groupBy = "strftime('%Y-%m-%d', created_unix, 'unixepoch')" | ||
case setting.UseMySQL: | ||
groupBy = "DATE_FORMAT(FROM_UNIXTIME(created_unix), '%Y%m%d')" | ||
case setting.UsePostgreSQL: | ||
groupBy = "date_trunc('day', created_unix)" | ||
case setting.UseMSSQL: | ||
groupBy = "dateadd(DAY,0, datediff(day,0, dateadd(s, created_unix, '19700101')))" | ||
} | ||
|
||
err = x.Select("created_unix as timestamp, count(user_id) as contributions"). | ||
Table("action"). | ||
Where("user_id = ?", user.ID). | ||
And("created_unix > ?", (util.TimeStampNow() - 31536000)). | ||
GroupBy(groupBy). | ||
OrderBy("created_unix"). | ||
Find(&hdata) | ||
return | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package models | ||
kolaente marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestGetUserHeatmapDataByUser(t *testing.T) { | ||
// Prepare | ||
assert.NoError(t, PrepareTestDatabase()) | ||
|
||
// Insert some action | ||
user := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) | ||
|
||
// get the action for comparison | ||
actions, err := GetFeeds(GetFeedsOptions{ | ||
RequestedUser: user, | ||
RequestingUserID: user.ID, | ||
IncludePrivate: true, | ||
OnlyPerformedBy: false, | ||
IncludeDeleted: true, | ||
}) | ||
assert.NoError(t, err) | ||
|
||
// Get the heatmap and compare | ||
heatmap, err := GetUserHeatmapDataByUser(user) | ||
assert.NoError(t, err) | ||
assert.Equal(t, len(actions), len(heatmap)) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
public/vendor/plugins/calendar-heatmap/calendar-heatmap.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
text.month-name, | ||
text.calendar-heatmap-legend-text, | ||
text.day-initial { | ||
font-size: 10px; | ||
fill: inherit; | ||
font-family: Helvetica, arial, 'Open Sans', sans-serif; | ||
} | ||
rect.day-cell:hover { | ||
stroke: #555555; | ||
stroke-width: 1px; | ||
} | ||
.day-cell-tooltip { | ||
position: absolute; | ||
z-index: 9999; | ||
padding: 5px 9px; | ||
color: #bbbbbb; | ||
font-size: 12px; | ||
background: rgba(0, 0, 0, 0.85); | ||
border-radius: 3px; | ||
text-align: center; | ||
} | ||
.day-cell-tooltip > span { | ||
font-family: Helvetica, arial, 'Open Sans', sans-serif | ||
} | ||
.calendar-heatmap { | ||
box-sizing: initial; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.