1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: GET /heartbeat endpoint (resolves #241)

This commit is contained in:
Steven Tang
2022-01-28 22:28:47 +11:00
committed by Ferdinand Mütsch
parent 7159df30c2
commit e7f3432113
9 changed files with 638 additions and 9 deletions

View File

@ -160,6 +160,48 @@ var doc = `{
}
},
"/compat/wakatime/v1/users/{user}/heartbeats": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"tags": [
"heartbeat"
],
"summary": "Get heartbeats of user for specified date",
"operationId": "get-heartbeats",
"parameters": [
{
"type": "string",
"description": "Date",
"name": "date",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.HeartbeatEntry"
}
},
"400": {
"description": "bad date",
"schema": {
"type": "string"
}
}
}
},
"post": {
"security": [
{
@ -183,6 +225,13 @@ var doc = `{
"schema": {
"$ref": "#/definitions/models.Heartbeat"
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -219,6 +268,13 @@ var doc = `{
"$ref": "#/definitions/models.Heartbeat"
}
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -863,6 +919,13 @@ var doc = `{
"schema": {
"$ref": "#/definitions/models.Heartbeat"
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -899,6 +962,13 @@ var doc = `{
"$ref": "#/definitions/models.Heartbeat"
}
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -967,6 +1037,13 @@ var doc = `{
"schema": {
"$ref": "#/definitions/models.Heartbeat"
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -1003,6 +1080,13 @@ var doc = `{
"$ref": "#/definitions/models.Heartbeat"
}
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -1094,6 +1178,13 @@ var doc = `{
"models.Summary": {
"type": "object",
"properties": {
"branches": {
"description": "branches are not persisted, but calculated at runtime in case a project filter is applied",
"type": "array",
"items": {
"$ref": "#/definitions/models.SummaryItem"
}
},
"editors": {
"type": "array",
"items": {
@ -1222,6 +1313,50 @@ var doc = `{
}
}
},
"v1.HeartbeatEntry": {
"type": "object",
"properties": {
"branch": {
"type": "string"
},
"category": {
"type": "string"
},
"created_at": {
"type": "string"
},
"entity": {
"type": "string"
},
"id": {
"type": "string"
},
"is_write": {
"type": "boolean"
},
"language": {
"type": "string"
},
"machine_name_id": {
"type": "string"
},
"project": {
"type": "string"
},
"time": {
"type": "number"
},
"type": {
"type": "string"
},
"user_agent_id": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"v1.Project": {
"type": "object",
"properties": {
@ -1250,6 +1385,12 @@ var doc = `{
"v1.StatsData": {
"type": "object",
"properties": {
"branches": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.SummariesEntry"
}
},
"daily_average": {
"type": "number"
},
@ -1325,6 +1466,12 @@ var doc = `{
"v1.SummariesData": {
"type": "object",
"properties": {
"branches": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.SummariesEntry"
}
},
"categories": {
"type": "array",
"items": {

View File

@ -145,6 +145,48 @@
}
},
"/compat/wakatime/v1/users/{user}/heartbeats": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"tags": [
"heartbeat"
],
"summary": "Get heartbeats of user for specified date",
"operationId": "get-heartbeats",
"parameters": [
{
"type": "string",
"description": "Date",
"name": "date",
"in": "query",
"required": true
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.HeartbeatEntry"
}
},
"400": {
"description": "bad date",
"schema": {
"type": "string"
}
}
}
},
"post": {
"security": [
{
@ -168,6 +210,13 @@
"schema": {
"$ref": "#/definitions/models.Heartbeat"
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -204,6 +253,13 @@
"$ref": "#/definitions/models.Heartbeat"
}
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -848,6 +904,13 @@
"schema": {
"$ref": "#/definitions/models.Heartbeat"
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -884,6 +947,13 @@
"$ref": "#/definitions/models.Heartbeat"
}
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -952,6 +1022,13 @@
"schema": {
"$ref": "#/definitions/models.Heartbeat"
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -988,6 +1065,13 @@
"$ref": "#/definitions/models.Heartbeat"
}
}
},
{
"type": "string",
"description": "Username (or current)",
"name": "user",
"in": "path",
"required": true
}
],
"responses": {
@ -1079,6 +1163,13 @@
"models.Summary": {
"type": "object",
"properties": {
"branches": {
"description": "branches are not persisted, but calculated at runtime in case a project filter is applied",
"type": "array",
"items": {
"$ref": "#/definitions/models.SummaryItem"
}
},
"editors": {
"type": "array",
"items": {
@ -1207,6 +1298,50 @@
}
}
},
"v1.HeartbeatEntry": {
"type": "object",
"properties": {
"branch": {
"type": "string"
},
"category": {
"type": "string"
},
"created_at": {
"type": "string"
},
"entity": {
"type": "string"
},
"id": {
"type": "string"
},
"is_write": {
"type": "boolean"
},
"language": {
"type": "string"
},
"machine_name_id": {
"type": "string"
},
"project": {
"type": "string"
},
"time": {
"type": "number"
},
"type": {
"type": "string"
},
"user_agent_id": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"v1.Project": {
"type": "object",
"properties": {
@ -1235,6 +1370,12 @@
"v1.StatsData": {
"type": "object",
"properties": {
"branches": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.SummariesEntry"
}
},
"daily_average": {
"type": "number"
},
@ -1310,6 +1451,12 @@
"v1.SummariesData": {
"type": "object",
"properties": {
"branches": {
"type": "array",
"items": {
"$ref": "#/definitions/v1.SummariesEntry"
}
},
"categories": {
"type": "array",
"items": {

View File

@ -54,6 +54,12 @@ definitions:
type: object
models.Summary:
properties:
branches:
description: branches are not persisted, but calculated at runtime in case
a project filter is applied
items:
$ref: '#/definitions/models.SummaryItem'
type: array
editors:
items:
$ref: '#/definitions/models.SummaryItem'
@ -142,6 +148,35 @@ definitions:
schemaVersion:
type: integer
type: object
v1.HeartbeatEntry:
properties:
branch:
type: string
category:
type: string
created_at:
type: string
entity:
type: string
id:
type: string
is_write:
type: boolean
language:
type: string
machine_name_id:
type: string
project:
type: string
time:
type: number
type:
type: string
user_agent_id:
type: string
user_id:
type: string
type: object
v1.Project:
properties:
id:
@ -160,6 +195,10 @@ definitions:
type: object
v1.StatsData:
properties:
branches:
items:
$ref: '#/definitions/v1.SummariesEntry'
type: array
daily_average:
type: number
days_including_holidays:
@ -209,6 +248,10 @@ definitions:
type: object
v1.SummariesData:
properties:
branches:
items:
$ref: '#/definitions/v1.SummariesEntry'
type: array
categories:
items:
$ref: '#/definitions/v1.SummariesEntry'
@ -441,6 +484,33 @@ paths:
tags:
- wakatime
/compat/wakatime/v1/users/{user}/heartbeats:
get:
operationId: get-heartbeats
parameters:
- description: Date
in: query
name: date
required: true
type: string
- description: Username (or current)
in: path
name: user
required: true
type: string
responses:
"200":
description: OK
schema:
$ref: '#/definitions/v1.HeartbeatEntry'
"400":
description: bad date
schema:
type: string
security:
- ApiKeyAuth: []
summary: Get heartbeats of user for specified date
tags:
- heartbeat
post:
consumes:
- application/json
@ -452,6 +522,11 @@ paths:
required: true
schema:
$ref: '#/definitions/models.Heartbeat'
- description: Username (or current)
in: path
name: user
required: true
type: string
responses:
"201":
description: ""
@ -474,6 +549,11 @@ paths:
items:
$ref: '#/definitions/models.Heartbeat'
type: array
- description: Username (or current)
in: path
name: user
required: true
type: string
responses:
"201":
description: ""
@ -900,6 +980,11 @@ paths:
required: true
schema:
$ref: '#/definitions/models.Heartbeat'
- description: Username (or current)
in: path
name: user
required: true
type: string
responses:
"201":
description: ""
@ -922,6 +1007,11 @@ paths:
items:
$ref: '#/definitions/models.Heartbeat'
type: array
- description: Username (or current)
in: path
name: user
required: true
type: string
responses:
"201":
description: ""
@ -965,6 +1055,11 @@ paths:
required: true
schema:
$ref: '#/definitions/models.Heartbeat'
- description: Username (or current)
in: path
name: user
required: true
type: string
responses:
"201":
description: ""
@ -987,6 +1082,11 @@ paths:
items:
$ref: '#/definitions/models.Heartbeat'
type: array
- description: Username (or current)
in: path
name: user
required: true
type: string
responses:
"201":
description: ""