Skip to content
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

User action heatmap #5131

Merged
merged 34 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
26bb85f
Added basic heatmap data
kolaente Oct 20, 2018
f27fe68
Added extra case for sqlite
kolaente Oct 20, 2018
af87a62
Built basic heatmap into user profile
kolaente Oct 20, 2018
562257c
Get contribution data from api & styling
kolaente Oct 20, 2018
1a36952
Fixed lint & added extra group by statements for all database types
kolaente Oct 20, 2018
1ae7ed2
generated swagger spec
kolaente Oct 20, 2018
7823d45
generated swagger spec
kolaente Oct 20, 2018
3f2562a
generated swagger spec
kolaente Oct 20, 2018
a1d3fb7
fixed swagger spec
kolaente Oct 20, 2018
5d99fc5
fmt
kolaente Oct 20, 2018
63cf602
Added tests
kolaente Oct 20, 2018
b01dcd2
Added setting to enable/disable user heatmap
kolaente Oct 20, 2018
cac8299
Added locale for loading text
kolaente Oct 20, 2018
a831999
Removed UseTiDB
kolaente Oct 20, 2018
068eaaf
Merge branch 'master' into feature/commit-heatmap
kolaente Oct 20, 2018
fdd3132
Updated librejs & moment.js
kolaente Oct 20, 2018
dd04de8
Merge remote-tracking branch 'origin/feature/commit-heatmap' into fea…
kolaente Oct 20, 2018
86aa012
Merge branch 'master' into feature/commit-heatmap
kolaente Oct 20, 2018
8fb9857
Merge branch 'master' into feature/commit-heatmap
kolaente Oct 20, 2018
3a85ca7
Fixed import order
kolaente Oct 20, 2018
bed8f3c
Merge remote-tracking branch 'origin/feature/commit-heatmap' into fea…
kolaente Oct 20, 2018
6e9519f
Fixed heatmap in postgresql
kolaente Oct 21, 2018
6d724e6
Update docs/content/doc/advanced/config-cheat-sheet.en-us.md
sapk Oct 21, 2018
7ecaeac
Merge branch 'master' into feature/commit-heatmap
kolaente Oct 21, 2018
9db3069
Added copyright header
kolaente Oct 21, 2018
2ea5a1e
Fixed a bug to show the heatmap for the actual user instead of the cu…
kolaente Oct 21, 2018
06846be
Added integration test for heatmaps
kolaente Oct 21, 2018
20a35d6
Added a heatmap on the dashboard
kolaente Oct 21, 2018
81d98ed
Fixed timestamp parsing
kolaente Oct 21, 2018
e441242
Merge branch 'master' into feature/commit-heatmap
kolaente Oct 21, 2018
8de8db1
Hide heatmap on mobile
kolaente Oct 21, 2018
9c0e184
optimized postgresql group by query
kolaente Oct 21, 2018
727171a
Improved sqlite group by statement
kolaente Oct 22, 2018
e8a7559
Merge branch 'master' into feature/commit-heatmap
lunny Oct 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get contribution data from api & styling
  • Loading branch information
kolaente committed Oct 20, 2018
commit 562257c713be1bf499af1b30445a1b0b59d1fb34
4 changes: 2 additions & 2 deletions models/user_heatmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
)

type UserHeatmapData struct {
Timestamp util.TimeStamp `json:"date"`
Contributions int64 `json:"count"`
Timestamp util.TimeStamp `json:"timestamp"`
Contributions int64 `json:"contributions"`
}

func GetUserHeatmapDataByUser(user *User) (hdata []*UserHeatmapData, err error) {
Expand Down
2 changes: 1 addition & 1 deletion public/css/index.css

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion public/less/_user.less
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@
margin-top: 25px;
}

kolaente marked this conversation as resolved.
Show resolved Hide resolved
#cal-heatmap{
#loading-heatmap{
margin-bottom: 1em;
}

#user-heatmap{
width: 107%; // Fixes newest contributions not showing

svg:not(:root) {
Expand Down
2 changes: 1 addition & 1 deletion public/vendor/plugins/calendar-heatmap/calendar-heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function calendarHeatmap() {
var tooltipUnit = 'contribution';
var legendEnabled = true;
var onClick = null;
var weekStart = 0; //0 for Sunday, 1 for Monday
var weekStart = 1; //0 for Sunday, 1 for Monday
var locale = {
months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
days: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
Expand Down
34 changes: 13 additions & 21 deletions templates/base/footer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,21 @@
<script src="{{AppSubUrl}}/vendor/plugins/d3/d3.v4.min.js" charset="utf-8"></script>
<script src="{{AppSubUrl}}/vendor/plugins/calendar-heatmap/calendar-heatmap.js" charset="utf-8"></script>
<script type="text/javascript">
var chartRawData = [
{"date":1531766422,"count":3},
{"date":1532422453,"count":1},
{"date":1538577294,"count":3},
{"date":1539803278,"count":5},
{"date":1539852016,"count":4},
{"date":1540036193,"count":1}
];

var chartData = [];
for (var i = 0; i < chartRawData.length; i++) {
chartData[i] = {date: new Date(chartRawData[i].date * 1000), count: chartRawData[i].count};
}
$.get( '{{AppSubUrl}}/api/v1/users/{{.Owner.Name}}/heatmap', function( chartRawData ) {
var chartData = [];
for (var i = 0; i < chartRawData.length; i++) {
chartData[i] = {date: new Date(chartRawData[i].timestamp * 1000), count: chartRawData[i].contributions};
}

console.log(chartRawData);
console.log(chartData);
$('#loading-heatmap').removeClass('active');

var heatmap = calendarHeatmap()
.data(chartData)
.selector('#cal-heatmap')
.colorRange(['#f4f4f4', '#267b57'])
.tooltipEnabled(true);
heatmap();
var heatmap = calendarHeatmap()
.data(chartData)
.selector('#user-heatmap')
.colorRange(['#f4f4f4', '#459928'])
.tooltipEnabled(true);
heatmap();
});
</script>
{{end}}
{{if .RequireTribute}}
Expand Down
3 changes: 2 additions & 1 deletion templates/user/profile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
</div>

{{if eq .TabName "activity"}}
<div id="cal-heatmap"></div>
<div class="ui active centered inline indeterminate text loader" id="loading-heatmap">Loading Heatmap...</div>
<div id="user-heatmap"></div>
<div class="feeds">
{{template "user/dashboard/feeds" .}}
</div>
Expand Down