Example #1
0
func GetAllMembers() ([]model.Member, error) {
	db, err := utils.GetDefaultDb()
	if err != nil {
		return nil, err
	}
	defer db.Close()
	var members []model.Member
	db.Find(&members)
	return members, nil
}
Example #2
0
func GetTasksByIterations(iterationId string) ([]model.Task, error) {
	db, err := utils.GetDefaultDb()
	if err != nil {
		return nil, err
	}
	defer db.Close()
	log.Debugf("Get Tasks by iterationId: %s", iterationId)
	var tasks []model.Task
	db.Where("iteration_id = ?", iterationId).Find(&tasks)
	return tasks, nil
}
Example #3
0
func GetMember(id string) (*model.Member, error) {
	db, err := utils.GetDefaultDb()
	if err != nil {
		return nil, err
	}
	defer db.Close()
	var members []model.Member
	db.Where(&model.Member{MemberId: &id}).Find(&members)
	if len(members) != 1 {
		return nil, fmt.Errorf("Get Member by id %s error.Result %#v", id, members)
	}
	return &members[0], nil
}
Example #4
0
func AddNewMember(member model.Member) (bool, error) {
	db, err := utils.GetDefaultDb()
	if err != nil {
		return false, err
	}
	defer db.Close()
	log.Infof("Add new member %#v", member)
	err = db.Create(&member).Error
	if err != nil {
		log.Error(err)
		return false, err
	}
	result := db.NewRecord(member)
	return !result, nil
}
Example #5
0
func AddTask(task model.Task) (bool, error) {
	db, err := utils.GetDefaultDb()
	if err != nil {
		return false, err
	}
	defer db.Close()
	task.SetTime()
	log.Infof("Add new Task %#v", task)
	err = db.Create(&task).Error
	if err != nil {
		return false, err
	}
	result := db.NewRecord(task)
	return !result, nil
}
Example #6
0
func GetIterationById(id string) (*model.Iteration, error) {
	db, err := utils.GetDefaultDb()
	if err != nil {
		return nil, err
	}
	defer db.Close()
	var iterations []model.Iteration
	db.Where("iteration_id = ?", id).Find(&iterations)
	if len(iterations) != 1 {
		return nil, fmt.Errorf("Iteration Id %s not found. %#v", id, iterations)
	}
	ret := &iterations[0]
	ret.SetDate()
	return ret, nil
}
Example #7
0
func AddIteration(iteration model.Iteration) (bool, error) {
	db, err := utils.GetDefaultDb()
	if err != nil {
		return false, err
	}
	defer db.Close()
	iteration.SetTime()
	log.Infof("Add new iteration %#v", iteration)
	err = db.Create(&iteration).Error
	if err != nil {
		return false, err
	}
	result := db.NewRecord(iteration)
	return !result, nil
}
Example #8
0
func GetAllIterations() ([]*model.Iteration, error) {
	db, err := utils.GetDefaultDb()
	log.Debug("Start Get all iterations.")
	if err != nil {
		return nil, err
	}
	defer db.Close()
	var iterations []model.Iteration
	err = db.Find(&iterations).Error
	if err != nil {
		log.Error(err)
		return nil, err
	}
	ret := []*model.Iteration{}
	for _, i := range iterations {
		i.SetDate()
		ret = append(ret, &i)
	}
	log.Debug("Start Get all iterations.")
	return ret, nil
}