Assignees optimizations #47

Merged
konrad merged 10 commits from enhancement/assignees-performance into master 2019-01-08 19:13:07 +00:00
4 changed files with 439 additions and 41 deletions
Showing only changes of commit 37ae1611a4 - Show all commits

View File

@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2019-01-03 22:32:38.523459581 +0100 CET m=+0.109277724
// 2019-01-07 22:44:21.325472216 +0100 CET m=+0.109716359
package docs
@ -37,7 +37,7 @@ var doc = `{
"JWTKeyAuth": []
}
],
"description": "Returns all labels which are either created by the user or associated with a task the user has at least read-access to.",
"description": "Returns an array with all assignees for this task.",
"consumes": [
"application/json"
],
@ -45,9 +45,9 @@ var doc = `{
"application/json"
],
"tags": [
"labels"
"assignees"
],
"summary": "Get all labels a user has access to",
"summary": "Get all assignees for a task",
"parameters": [
{
"type": "integer",
@ -57,18 +57,18 @@ var doc = `{
},
{
"type": "string",
"description": "Search labels by label text.",
"description": "Search assignees by their username.",
"name": "s",
"in": "query"
}
],
"responses": {
"200": {
"description": "The labels",
"description": "The assignees",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Label"
"$ref": "#/definitions/models.User"
}
}
},
@ -391,7 +391,7 @@ var doc = `{
"JWTKeyAuth": []
}
],
"description": "Returns a team by its ID.",
"description": "Returns a list by its ID.",
"consumes": [
"application/json"
],
@ -399,13 +399,13 @@ var doc = `{
"application/json"
],
"tags": [
"team"
"list"
],
"summary": "Gets one team",
"summary": "Gets one list",
"parameters": [
{
"type": "integer",
"description": "Team ID",
"description": "List ID",
"name": "id",
"in": "path",
"required": true
@ -413,14 +413,14 @@ var doc = `{
],
"responses": {
"200": {
"description": "The team",
"description": "The list",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Team"
"$ref": "#/definitions/models.List"
}
},
"403": {
"description": "The user does not have access to the team",
"description": "The user does not have access to the list",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io.web.HTTPError"
@ -2649,6 +2649,127 @@ var doc = `{
}
}
},
"/tasks/{taskID}/assignees": {
"put": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Adds a new assignee to a task. The assignee needs to have access to the list, the doer must be able to edit this task.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"assignees"
],
"summary": "Add a new assignee to a task",
"parameters": [
{
"description": "The assingee object",
"name": "assignee",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/models.ListTaskAssginee"
}
},
{
"type": "integer",
"description": "Task ID",
"name": "taskID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "The created assingee object.",
"schema": {
"type": "object",
"$ref": "#/definitions/models.ListTaskAssginee"
}
},
"400": {
"description": "Invalid assignee object provided.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io.web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/tasks/{taskID}/assignees/{userID}": {
"delete": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Un-assign a user from a task.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"assignees"
],
"summary": "Delete an assignee",
"parameters": [
{
"type": "integer",
"description": "Task ID",
"name": "taskID",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Assignee ID",
"name": "userID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "The assignee was successfully deleted.",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
},
"403": {
"description": "Not allowed to delete the assignee.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io.web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/tasks/{task}/labels": {
"get": {
"security": [
@ -3795,6 +3916,17 @@ var doc = `{
}
}
},
"models.ListTaskAssginee": {
"type": "object",
"properties": {
"created": {
"type": "integer"
},
"user_id": {
"type": "integer"
}
}
},
"models.ListUser": {
"type": "object",
"properties": {
@ -4081,6 +4213,10 @@ var doc = `{
"team_id": {
"description": "The team id.",
"type": "integer"
},
"updated": {
"description": "A unix timestamp when this relation was last updated. You cannot change this value.",
"type": "integer"
}
}
},

View File

@ -24,7 +24,7 @@
"JWTKeyAuth": []
}
],
"description": "Returns all labels which are either created by the user or associated with a task the user has at least read-access to.",
"description": "Returns an array with all assignees for this task.",
"consumes": [
"application/json"
],
@ -32,9 +32,9 @@
"application/json"
],
"tags": [
"labels"
"assignees"
],
"summary": "Get all labels a user has access to",
"summary": "Get all assignees for a task",
"parameters": [
{
"type": "integer",
@ -44,18 +44,18 @@
},
{
"type": "string",
"description": "Search labels by label text.",
"description": "Search assignees by their username.",
"name": "s",
"in": "query"
}
],
"responses": {
"200": {
"description": "The labels",
"description": "The assignees",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Label"
"$ref": "#/definitions/models.User"
}
}
},
@ -378,7 +378,7 @@
"JWTKeyAuth": []
}
],
"description": "Returns a team by its ID.",
"description": "Returns a list by its ID.",
"consumes": [
"application/json"
],
@ -386,13 +386,13 @@
"application/json"
],
"tags": [
"team"
"list"
],
"summary": "Gets one team",
"summary": "Gets one list",
"parameters": [
{
"type": "integer",
"description": "Team ID",
"description": "List ID",
"name": "id",
"in": "path",
"required": true
@ -400,14 +400,14 @@
],
"responses": {
"200": {
"description": "The team",
"description": "The list",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Team"
"$ref": "#/definitions/models.List"
}
},
"403": {
"description": "The user does not have access to the team",
"description": "The user does not have access to the list",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io/web.HTTPError"
@ -2636,6 +2636,127 @@
}
}
},
"/tasks/{taskID}/assignees": {
"put": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Adds a new assignee to a task. The assignee needs to have access to the list, the doer must be able to edit this task.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"assignees"
],
"summary": "Add a new assignee to a task",
"parameters": [
{
"description": "The assingee object",
"name": "assignee",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/models.ListTaskAssginee"
}
},
{
"type": "integer",
"description": "Task ID",
"name": "taskID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "The created assingee object.",
"schema": {
"type": "object",
"$ref": "#/definitions/models.ListTaskAssginee"
}
},
"400": {
"description": "Invalid assignee object provided.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io/web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/tasks/{taskID}/assignees/{userID}": {
"delete": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Un-assign a user from a task.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"assignees"
],
"summary": "Delete an assignee",
"parameters": [
{
"type": "integer",
"description": "Task ID",
"name": "taskID",
"in": "path",
"required": true
},
{
"type": "integer",
"description": "Assignee ID",
"name": "userID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "The assignee was successfully deleted.",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
},
"403": {
"description": "Not allowed to delete the assignee.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io/web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/tasks/{task}/labels": {
"get": {
"security": [
@ -3781,6 +3902,17 @@
}
}
},
"models.ListTaskAssginee": {
"type": "object",
"properties": {
"created": {
"type": "integer"
},
"user_id": {
"type": "integer"
}
}
},
"models.ListUser": {
"type": "object",
"properties": {
@ -4067,6 +4199,10 @@
"team_id": {
"description": "The team id.",
"type": "integer"
},
"updated": {
"description": "A unix timestamp when this relation was last updated. You cannot change this value.",
"type": "integer"
}
}
},

View File

@ -244,6 +244,13 @@ definitions:
change this value.
type: integer
type: object
models.ListTaskAssginee:
properties:
created:
type: integer
user_id:
type: integer
type: object
models.ListUser:
properties:
created:
@ -475,6 +482,10 @@ definitions:
team_id:
description: The team id.
type: integer
updated:
description: A unix timestamp when this relation was last updated. You cannot
change this value.
type: integer
type: object
models.TeamUser:
properties:
@ -630,15 +641,14 @@ paths:
get:
consumes:
- application/json
description: Returns all labels which are either created by the user or associated
with a task the user has at least read-access to.
description: Returns an array with all assignees for this task.
parameters:
- description: The page number. Used for pagination. If not provided, the first
page of results is returned.
in: query
name: p
type: integer
- description: Search labels by label text.
- description: Search assignees by their username.
in: query
name: s
type: string
@ -646,10 +656,10 @@ paths:
- application/json
responses:
"200":
description: The labels
description: The assignees
schema:
items:
$ref: '#/definitions/models.Label'
$ref: '#/definitions/models.User'
type: array
"500":
description: Internal error
@ -658,9 +668,9 @@ paths:
type: object
security:
- JWTKeyAuth: []
summary: Get all labels a user has access to
summary: Get all assignees for a task
tags:
- labels
- assignees
put:
consumes:
- application/json
@ -904,9 +914,9 @@ paths:
get:
consumes:
- application/json
description: Returns a team by its ID.
description: Returns a list by its ID.
parameters:
- description: Team ID
- description: List ID
in: path
name: id
required: true
@ -915,12 +925,12 @@ paths:
- application/json
responses:
"200":
description: The team
description: The list
schema:
$ref: '#/definitions/models.Team'
$ref: '#/definitions/models.List'
type: object
"403":
description: The user does not have access to the team
description: The user does not have access to the list
schema:
$ref: '#/definitions/code.vikunja.io/web.HTTPError'
type: object
@ -931,9 +941,9 @@ paths:
type: object
security:
- JWTKeyAuth: []
summary: Gets one team
summary: Gets one list
tags:
- team
- list
post:
consumes:
- application/json
@ -2341,6 +2351,87 @@ paths:
summary: Remove a label from a task
tags:
- labels
/tasks/{taskID}/assignees:
put:
consumes:
- application/json
description: Adds a new assignee to a task. The assignee needs to have access
to the list, the doer must be able to edit this task.
parameters:
- description: The assingee object
in: body
name: assignee
required: true
schema:
$ref: '#/definitions/models.ListTaskAssginee'
type: object
- description: Task ID
in: path
name: taskID
required: true
type: integer
produces:
- application/json
responses:
"200":
description: The created assingee object.
schema:
$ref: '#/definitions/models.ListTaskAssginee'
type: object
"400":
description: Invalid assignee object provided.
schema:
$ref: '#/definitions/code.vikunja.io/web.HTTPError'
type: object
"500":
description: Internal error
schema:
$ref: '#/definitions/models.Message'
type: object
security:
- JWTKeyAuth: []
summary: Add a new assignee to a task
tags:
- assignees
/tasks/{taskID}/assignees/{userID}:
delete:
consumes:
- application/json
description: Un-assign a user from a task.
parameters:
- description: Task ID
in: path
name: taskID
required: true
type: integer
- description: Assignee ID
in: path
name: userID
required: true
type: integer
produces:
- application/json
responses:
"200":
description: The assignee was successfully deleted.
schema:
$ref: '#/definitions/models.Message'
type: object
"403":
description: Not allowed to delete the assignee.
schema:
$ref: '#/definitions/code.vikunja.io/web.HTTPError'
type: object
"500":
description: Internal error
schema:
$ref: '#/definitions/models.Message'
type: object
security:
- JWTKeyAuth: []
summary: Delete an assignee
tags:
- assignees
/tasks/all:
get:
consumes:

View File

@ -128,12 +128,36 @@ func (t *ListTask) updateTaskAssignees(assignees []*User) (err error) {
}
// Delete a task assignee
// @Summary Delete an assignee
// @Description Un-assign a user from a task.
// @tags assignees
// @Accept json
// @Produce json
// @Security JWTKeyAuth
// @Param taskID path int true "Task ID"
// @Param userID path int true "Assignee user ID"
// @Success 200 {object} models.Message "The assignee was successfully deleted."
// @Failure 403 {object} code.vikunja.io/web.HTTPError "Not allowed to delete the assignee."
// @Failure 500 {object} models.Message "Internal error"
// @Router /tasks/{taskID}/assignees/{userID} [delete]
func (la *ListTaskAssginee) Delete() (err error) {
_, err = x.Delete(&ListTaskAssginee{TaskID: la.TaskID, UserID: la.UserID})
return
}
// Create adds a new assignee to a task
// @Summary Add a new assignee to a task
// @Description Adds a new assignee to a task. The assignee needs to have access to the list, the doer must be able to edit this task.
// @tags assignees
// @Accept json
// @Produce json
// @Security JWTKeyAuth
// @Param assignee body models.ListTaskAssginee true "The assingee object"
// @Param taskID path int true "Task ID"
// @Success 200 {object} models.ListTaskAssginee "The created assingee object."
// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid assignee object provided."
// @Failure 500 {object} models.Message "Internal error"
// @Router /tasks/{taskID}/assignees [put]
func (la *ListTaskAssginee) Create(a web.Auth) (err error) {
// Get the list to perform later checks
@ -166,6 +190,17 @@ func (t *ListTask) addNewAssigneeByID(newAssigneeID int64, list *List) (err erro
}
// ReadAll gets all assignees for a task
// @Summary Get all assignees for a task
// @Description Returns an array with all assignees for this task.
// @tags assignees
// @Accept json
// @Produce json
// @Param p query int false "The page number. Used for pagination. If not provided, the first page of results is returned."
// @Param s query string false "Search assignees by their username."
// @Security JWTKeyAuth
// @Success 200 {array} models.User "The assignees"
// @Failure 500 {object} models.Message "Internal error"
// @Router /labels [get]
func (la *ListTaskAssginee) ReadAll(search string, a web.Auth, page int) (interface{}, error) {
var taskAssignees []*User
err := x.Table("task_assignees").