Esempio n. 1
0
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
}
Esempio n. 2
0
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
}
Esempio n. 3
0
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
}
Esempio n. 4
0
func cleanTasks(sess db.Session) {
	coll, err := sess.Coll(CollName)
	if err != nil {
		panic(err)
	}
	coll.RemoveAll(bson.M{})
}
Esempio n. 5
0
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
}
Esempio n. 6
0
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)
}
Esempio n. 7
0
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,
	})
}