From 6759237eda5b7ddfe9284c81900cc9deed1f6bf9 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 23 Oct 2018 04:57:42 +0200 Subject: User action heatmap (#5131) * Added basic heatmap data * Added extra case for sqlite * Built basic heatmap into user profile * Get contribution data from api & styling * Fixed lint & added extra group by statements for all database types * generated swagger spec * generated swagger spec * generated swagger spec * fixed swagger spec * fmt * Added tests * Added setting to enable/disable user heatmap * Added locale for loading text * Removed UseTiDB * Updated librejs & moment.js * Fixed import order * Fixed heatmap in postgresql * Update docs/content/doc/advanced/config-cheat-sheet.en-us.md Co-Authored-By: kolaente * Added copyright header * Fixed a bug to show the heatmap for the actual user instead of the currently logged in * Added integration test for heatmaps * Added a heatmap on the dashboard * Fixed timestamp parsing * Hide heatmap on mobile * optimized postgresql group by query * Improved sqlite group by statement --- templates/base/footer.tmpl | 22 ++++++++++++ templates/base/head.tmpl | 3 ++ templates/swagger/v1_json.tmpl | 59 +++++++++++++++++++++++++++++++++ templates/user/dashboard/dashboard.tmpl | 5 +++ templates/user/profile.tmpl | 5 +++ 5 files changed, 94 insertions(+) (limited to 'templates') diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 0dd8871525..1734d32600 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -49,6 +49,28 @@ {{end}} {{end}} +{{if .EnableHeatmap}} + + + + +{{end}} {{if .RequireTribute}} diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index b6ab8141e2..130ab53755 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -100,6 +100,9 @@ {{end}} {{if .RequireDropzone}} +{{end}} +{{if .EnableHeatmap}} + {{end}} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 193579f6be..4987691fda 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -5494,6 +5494,35 @@ } } }, + "/users/{username}/heatmap": { + "get": { + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Get a user's heatmap", + "operationId": "userGetHeatmapData", + "parameters": [ + { + "type": "string", + "description": "username of user to get", + "name": "username", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "$ref": "#/responses/UserHeatmapData" + }, + "404": { + "$ref": "#/responses/notFound" + } + } + } + }, "/users/{username}/keys": { "get": { "produces": [ @@ -7666,6 +7695,12 @@ }, "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" }, + "TimeStamp": { + "description": "TimeStamp defines a timestamp", + "type": "integer", + "format": "int64", + "x-go-package": "code.gitea.io/gitea/modules/util" + }, "TrackedTime": { "description": "TrackedTime worked time for an issue / pr", "type": "object", @@ -7737,6 +7772,21 @@ }, "x-go-package": "code.gitea.io/gitea/vendor/code.gitea.io/sdk/gitea" }, + "UserHeatmapData": { + "description": "UserHeatmapData represents the data needed to create a heatmap", + "type": "object", + "properties": { + "contributions": { + "type": "integer", + "format": "int64", + "x-go-name": "Contributions" + }, + "timestamp": { + "$ref": "#/definitions/TimeStamp" + } + }, + "x-go-package": "code.gitea.io/gitea/models" + }, "WatchInfo": { "description": "WatchInfo represents an API watch status of one repository", "type": "object", @@ -8083,6 +8133,15 @@ "$ref": "#/definitions/User" } }, + "UserHeatmapData": { + "description": "UserHeatmapData", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/UserHeatmapData" + } + } + }, "UserList": { "description": "UserList", "schema": { diff --git a/templates/user/dashboard/dashboard.tmpl b/templates/user/dashboard/dashboard.tmpl index bddcc4925b..ac094f24c7 100644 --- a/templates/user/dashboard/dashboard.tmpl +++ b/templates/user/dashboard/dashboard.tmpl @@ -5,6 +5,11 @@ {{template "base/alert" .}}
+ {{if .EnableHeatmap}} +
{{.i18n.Tr "user.heatmap.loading"}}
+
+
+ {{end}} {{template "user/dashboard/feeds" .}}
diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 6cac300408..3f535ba140 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -95,6 +95,11 @@
{{if eq .TabName "activity"}} + {{if .EnableHeatmap}} +
{{.i18n.Tr "user.heatmap.loading"}}
+
+
+ {{end}}
{{template "user/dashboard/feeds" .}}
-- cgit v1.2.3