Skip to content

Commit a92d0f6

Browse files
committed
add status to assignment, assignment deactivator => assignment updater
1 parent b075861 commit a92d0f6

File tree

15 files changed

+62
-21
lines changed

15 files changed

+62
-21
lines changed

.idea/.gitignore

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/assignment.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

migrations/sql/1_create_assignments.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CREATE TABLE `assignments` (
44
`task_id` int(10) unsigned NOT NULL,
55
`response_id` int(10) unsigned DEFAULT NULL,
66
`worker_id` int(10) unsigned NOT NULL,
7-
`active` tinyint(1) NOT NULL DEFAULT '1',
7+
`status` varchar(20) NOT NULL DEFAULT 'active',
88
`assigned_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
99
`expires_at` timestamp NULL DEFAULT NULL,
1010
PRIMARY KEY (`id`),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CREATE TABLE `whitelists` (
22
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
3-
`job_id` int(11) unsigned NOT NULL,
43
`worker_id` int(11) unsigned NOT NULL,
4+
`job_id` int(11) unsigned NOT NULL,
55
PRIMARY KEY (`id`),
66
UNIQUE KEY `job_worker` (`job_id`,`worker_id`)
77
)
File renamed without changes.
File renamed without changes.

pkg/api/assignmentdeactivator/endpoint.go renamed to pkg/api/assignmentupdater/endpoint.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package assignmentdeactivator
1+
package assignmentupdater
22

33
import (
44
"context"
@@ -9,12 +9,12 @@ import (
99
"github.com/go-kit/kit/endpoint"
1010
)
1111

12-
func makeAssignmentDeactivatorEndpoint(svc service.AssignmentService) endpoint.Endpoint {
12+
func makeAssignmentUpdaterEndpoint(svc service.AssignmentService) endpoint.Endpoint {
1313
return func(ctx context.Context, request interface{}) (interface{}, error) {
1414
data, _ := authentication.ParseAuthData(ctx)
1515
svc.SetAuthData(data)
1616
req := request.(AssignmentRequest)
17-
p, err := svc.DeactivateAssignment(req.WorkerID, req.JobID)
17+
p, err := svc.UpdateAssignment(req.WorkerID, req.JobID, req.Status)
1818
if err != nil {
1919
return AssignmentResponse{p}, errorResponse(err)
2020
}
@@ -29,8 +29,9 @@ func errorResponse(err error) *apierror.APIError {
2929
type AssignmentRequest struct {
3030
WorkerID uint64 `json:"worker_id"`
3131
JobID uint64 `json:"job_id"`
32+
Status string `json:"status"`
3233
}
3334

3435
type AssignmentResponse struct {
35-
Deactivated bool `json:"deactivated"`
36+
Updated bool `json:"updated"`
3637
}

0 commit comments

Comments
 (0)