func Write(st db.Session, t *Task) error { col, err := st.Coll(CollName) if err != nil { return err } id, err := t.GetID() if err != nil { return err } t.ObjType.Set("task") if t.Search == nil { t.Search = kwd.NewKeywords() } if t.Events == nil { t.Events = evtype.NewEventList() } if t.TaskID.IsDefined() { t.Search["taskid"] = t.TaskID.String() } if t.Repo.IsDefined() { t.Search["repo"] = t.Repo.String() } _, err = col.Upsert(id, t) return err }
func List(st db.Session, query db.QueryDoc) (res db.Query, err error) { col, err := st.Coll(CollName) if err == nil { res = col.Find(query) } return }
func Write(st db.Session, t *SubTask) error { col, err := st.Coll(CollName) if err != nil { return err } id, err := t.GetID() if err != nil { return err } t.ObjType.Set("subtask") if t.Search == nil { t.Search = kwd.NewKeywords() } if t.Owner.IsDefined() { t.Search["owner"] = t.Owner.String() } if t.PkgName.IsDefined() { t.Search["pkgname"] = t.PkgName.String() } _, err = col.Upsert(id, t) return err }
func cleanTasks(sess db.Session) { coll, err := sess.Coll(CollName) if err != nil { panic(err) } coll.RemoveAll(bson.M{}) }
func Delete(st db.Session, query db.QueryDoc) error { col, err := st.Coll(CollName) if err != nil { return err } _, err = col.RemoveAll(query) return err }
func showTasks(sess db.Session) { coll, err := sess.Coll(CollName) if err != nil { panic(err) } var result []bson.M err = coll.Find(bson.M{}).All(&result) if err != nil { panic(err) } fmt.Printf("%+v\n", result) }
func initTasks(sess db.Session) { coll, err := sess.Coll(CollName) if err != nil { panic(err) } coll.Insert(bson.M{ "taskid": 149239, "objtype": "task", "try": 0, "iter": 1, "state": "new", "repo": "sisyphus", "owner": "legion", "aborted": "", "shared": false, "swift": false, "testonly": true, }) }