fix(be): delete schedule

This commit is contained in:
Denis Gukov 2021-09-09 23:56:15 +05:00
parent 7ca8da12f3
commit 1d72c32994
4 changed files with 47 additions and 18 deletions

View File

@ -10,7 +10,7 @@ import (
)
// STATE
// Runtime created objects we needs to reference in test setups
// Runtime created objects we need to reference in test setups
var testRunnerUser *db.User
var userPathTestUser *db.User
var userProject *db.Project

View File

@ -105,6 +105,10 @@ func main() {
h.Before("project > /api/project/{project_id}/tasks/{task_id} > Deletes task (including output) > 204 > application/json", capabilityWrapper("task"))
h.Before("project > /api/project/{project_id}/tasks/{task_id}/output > Get task output > 200 > application/json", capabilityWrapper("task"))
h.Before("schedule > /api/project/{project_id}/schedules/{schedule_id} > Get schedule > 200 > application/json", capabilityWrapper("schedule"))
h.Before("schedule > /api/project/{project_id}/schedules/{schedule_id} > Updates schedule > 204 > application/json", capabilityWrapper("schedule"))
h.Before("schedule > /api/project/{project_id}/schedules/{schedule_id} > Deletes schedule > 204 > application/json", capabilityWrapper("schedule"))
//Add these last as they normalize the requests and path values after hook processing
h.BeforeAll(func(transactions []*trans.Transaction) {
for _, t := range transactions {

View File

@ -470,6 +470,13 @@ parameters:
type: integer
required: true
x-example: 8
schedule_id:
name: schedule_id
description: schedule ID
in: path
type: integer
required: true
x-example: 9
paths:
/ping:
get:
@ -509,22 +516,6 @@ paths:
schema:
$ref: "#/definitions/InfoType"
# /upgrade:
# get:
# summary: Check if new updates available and fetch /info
# responses:
# 204:
# description: no update
# 200:
# description: ok
# schema:
# $ref: "#/definitions/InfoType"
# post:
# summary: Upgrade the server
# responses:
# 200:
# description: Server binary was replaced by new version, server has shut down.
# Authentication
/auth/login:
post:
@ -1228,6 +1219,40 @@ paths:
# project schedules
/project/{project_id}/schedules/{schedule_id}:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/schedule_id"
get:
tags:
- schedule
summary: Get schedule
responses:
200:
description: Schedule
schema:
$ref: "#/definitions/Schedule"
delete:
tags:
- schedule
summary: Deletes schedule
responses:
204:
description: schedule deleted
put:
tags:
- schedule
summary: Updates schedule
parameters:
- name: schedule
in: body
required: true
schema:
$ref: "#/definitions/ScheduleRequest"
responses:
204:
description: schedule updated
/project/{project_id}/schedules:
parameters:
- $ref: "#/parameters/project_id"

View File

@ -48,7 +48,7 @@ func (d *SqlDb) GetSchedule(projectID int, scheduleID int) (template db.Schedule
}
func (d *SqlDb) DeleteSchedule(projectID int, scheduleID int) error {
_, err := d.exec("delete project__schedule where project_id=? and id=?", projectID, scheduleID)
_, err := d.exec("delete from project__schedule where project_id=? and id=?", projectID, scheduleID)
return err
}