结果集自动生成

This commit is contained in:
marvzhang
2020-04-19 17:49:21 +08:00
parent 86ea474c9a
commit b0806d2e94
8 changed files with 55 additions and 40 deletions

View File

@@ -3,6 +3,7 @@ package model
import (
"crawlab/constants"
"crawlab/database"
"crawlab/utils"
"github.com/apex/log"
"github.com/globalsign/mgo/bson"
"runtime/debug"
@@ -89,11 +90,9 @@ func (t *Task) GetResults(pageNum int, pageSize int) (results []interface{}, tot
return
}
if spider.Col == "" {
return
}
col := utils.GetSpiderCol(spider.Col, spider.Name)
s, c := database.GetCol(spider.Col)
s, c := database.GetCol(col)
defer s.Close()
query := bson.M{
@@ -388,8 +387,11 @@ func UpdateTaskResultCount(id string) (err error) {
return err
}
// default results collection
col := utils.GetSpiderCol(spider.Col, spider.Name)
// 获取结果数量
s, c := database.GetCol(spider.Col)
s, c := database.GetCol(col)
defer s.Close()
resultCount, err := c.Find(bson.M{"task_id": task.Id}).Count()
if err != nil {