add ability to remove user and add task depndencies closes #69
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
type Task struct {
|
||||
Id string `db:"id" json:"id"`
|
||||
UserId string `db:"user_id" json:"user_id"`
|
||||
ModelId string `db:"model_id" json:"model_id"`
|
||||
ModelId *string `db:"model_id" json:"model_id"`
|
||||
Status int `db:"status" json:"status"`
|
||||
StatusMessage string `db:"status_message" json:"status_message"`
|
||||
UserConfirmed int `db:"user_confirmed" json:"user_confirmed"`
|
||||
@@ -21,6 +21,27 @@ type Task struct {
|
||||
CreatedOn time.Time `db:"created_on" json:"created"`
|
||||
}
|
||||
|
||||
// Find better way todo this
|
||||
type TaskT struct {
|
||||
Id string `db:"t.id" json:"id"`
|
||||
UserId string `db:"t.user_id" json:"user_id"`
|
||||
ModelId *string `db:"t.model_id" json:"model_id"`
|
||||
Status int `db:"t.status" json:"status"`
|
||||
StatusMessage string `db:"t.status_message" json:"status_message"`
|
||||
UserConfirmed int `db:"t.user_confirmed" json:"user_confirmed"`
|
||||
Compacted int `db:"t.compacted" json:"compacted"`
|
||||
TaskType int `db:"t.task_type" json:"type"`
|
||||
ExtraTaskInfo string `db:"t.extra_task_info" json:"extra_task_info"`
|
||||
Result string `db:"t.result" json:"result"`
|
||||
CreatedOn time.Time `db:"t.created_on" json:"created"`
|
||||
}
|
||||
|
||||
type TaskDependents struct {
|
||||
Id string `db:"id" json:"id"`
|
||||
MainId string `db:"main_id" json:"main_id"`
|
||||
DependentId string `db:"dependent_id" json:"dependent_id"`
|
||||
}
|
||||
|
||||
type TaskStatus int
|
||||
|
||||
const (
|
||||
@@ -39,6 +60,7 @@ const (
|
||||
TASK_TYPE_CLASSIFICATION TaskType = 1 + iota
|
||||
TASK_TYPE_TRAINING
|
||||
TASK_TYPE_RETRAINING
|
||||
TASK_TYPE_DELETE_USER
|
||||
)
|
||||
|
||||
type TaskAgreement int
|
||||
@@ -82,3 +104,15 @@ func (t Task) SetResult(base BasePack, result any) (err error) {
|
||||
_, err = base.GetDb().Exec("update tasks set result=$1 where id=$2", text, t.Id)
|
||||
return
|
||||
}
|
||||
|
||||
func (t Task) Depend(base BasePack, depend_id string) (err error) {
|
||||
var dependency = struct {
|
||||
Main string `db:"main_id"`
|
||||
Dependent string `db:"dependent_id"`
|
||||
}{
|
||||
Main: t.Id,
|
||||
Dependent: depend_id,
|
||||
}
|
||||
_, err = InsertReturnId(base.GetDb(), &dependency, "tasks_dependencies", "id")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user