revert accidental search&replace fail

This commit is contained in:
simon987
2019-02-16 09:56:44 -05:00
parent 6ca92bc0a7
commit 03153c4d39
20 changed files with 108 additions and 96 deletions

View File

@@ -9,7 +9,7 @@ import (
type Task struct {
Id int64 `json:"id"`
Priority int64 `json:"priority"`
Project *Project `json:"projectChange"`
Project *Project `json:"project"`
Assignee int64 `json:"assignee"`
Retries int64 `json:"retries"`
MaxRetries int64 `json:"max_retries"`
@@ -41,7 +41,7 @@ func (database *Database) SaveTask(task *Task, project int64, hash64 int64) erro
//TODO: For some reason it refuses to insert the 64-bit value unless I do that...
res, err := db.Exec(fmt.Sprintf(`
INSERT INTO task (projectChange, max_retries, recipe, priority, max_assign_time, hash64,verification_count)
INSERT INTO task (project, max_retries, recipe, priority, max_assign_time, hash64,verification_count)
VALUES ($1,$2,$3,$4,$5,NULLIF(%d, 0),$6)`, hash64),
project, task.MaxRetries, task.Recipe, task.Priority, task.MaxAssignTime, task.VerificationCount)
if err != nil {
@@ -73,11 +73,11 @@ func (database *Database) GetTask(worker *Worker) *Task {
(
SELECT task.id
FROM task
INNER JOIN projectChange project on task.projectChange = project.id
INNER JOIN project project on task.project = project.id
LEFT JOIN worker_verifies_task wvt on task.id = wvt.task AND wvt.worker=$1
WHERE assignee IS NULL AND task.status=1
AND (project.public OR EXISTS (
SELECT 1 FROM worker_has_access_to_project a WHERE a.worker=$1 AND a.projectChange=project.id
SELECT 1 FROM worker_has_access_to_project a WHERE a.worker=$1 AND a.project=project.id
))
AND wvt.task IS NULL
ORDER BY project.priority DESC, task.priority DESC
@@ -107,10 +107,10 @@ func (database *Database) GetTask(worker *Worker) *Task {
func getTaskById(id int64, db *sql.DB) *Task {
row := db.QueryRow(`
SELECT task.id, task.priority, task.projectChange, assignee, retries, max_retries,
SELECT task.id, task.priority, task.project, assignee, retries, max_retries,
status, recipe, max_assign_time, assign_time, verification_count, project.priority, project.name,
project.clone_url, project.git_repo, project.version, project.motd, project.public, COALESCE(project.chain,0) FROM task
INNER JOIN projectChange project ON task.projectChange = project.id
INNER JOIN project project ON task.project = project.id
WHERE task.id=$1`, id)
project := &Project{}
task := &Task{}
@@ -176,11 +176,11 @@ func (database *Database) GetTaskFromProject(worker *Worker, projectId int64) *T
(
SELECT task.id
FROM task
INNER JOIN projectChange project on task.projectChange = project.id
INNER JOIN project project on task.project = project.id
LEFT JOIN worker_verifies_task wvt on task.id = wvt.task AND wvt.worker=$1
WHERE assignee IS NULL AND project.id=$2 AND status=1
AND (project.public OR EXISTS (
SELECT 1 FROM worker_has_access_to_project a WHERE a.worker=$1 AND a.projectChange=$2
SELECT 1 FROM worker_has_access_to_project a WHERE a.worker=$1 AND a.project=$2
))
AND wvt.task IS NULL
ORDER BY task.priority DESC