Ejemplo n.º 1
0
func (this *solution) UpdateRecord() {
	if this.Module != config.ModuleP {
		return
	}

	solutionModel := model.SolutionModel{}
	qry := make(map[string]string)
	qry["module"] = strconv.Itoa(config.ModuleP)
	qry["action"] = "submit"
	qry["pid"] = strconv.Itoa(this.Pid)

	submit, _ := solutionModel.Count(qry)

	qry["action"] = "solve"
	solve, _ := solutionModel.Count(qry)

	proModel := model.ProblemModel{}
	err := proModel.Record(this.Pid, solve, submit)
	if err != nil {
		logger.Println(err)
	}

	qry["action"] = "submit"
	qry["uid"] = this.Uid
	delete(qry, "pid")
	delete(qry, "module")
	submit, _ = solutionModel.Count(qry)

	solvelist, err := solutionModel.Achieve(this.Uid, config.ModuleP, config.ModuleP)
	if err != nil {
		logger.Println(err)
	}
	solve = len(solvelist)

	userModel := model.UserModel{}
	err = userModel.Record(this.Uid, solve, submit)
	if err != nil {
		logger.Println(err)
	}
}