Files
crawlab/backend/services/challenge/run_random.go
2020-03-19 18:56:59 +08:00

25 lines
454 B
Go

package challenge
import (
"crawlab/constants"
"crawlab/model"
"github.com/globalsign/mgo/bson"
)
type RunRandomService struct {
UserId bson.ObjectId
}
func (s *RunRandomService) Check() (bool, error) {
query := bson.M{
"user_id": s.UserId,
"run_type": constants.RunTypeRandom,
"status": constants.StatusFinished,
}
list, err := model.GetTaskList(query, 0, 1, "-_id")
if err != nil {
return false, err
}
return len(list) > 0, nil
}