拆解子任务
This commit is contained in:
parent
eba36b0c95
commit
6197f445bf
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,3 +4,5 @@ screenlog.*
|
|||
*.7z
|
||||
intimate
|
||||
*.gz
|
||||
|
||||
|
||||
|
|
11
config.go
11
config.go
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package intimate
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -8,6 +8,15 @@ import (
|
|||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// InitConfig 初始化配置加载 config.yaml(yml)
|
||||
var InitConfig *Config
|
||||
|
||||
func init() {
|
||||
InitConfig = &Config{}
|
||||
InitConfig.Load()
|
||||
// storeOpenrec = NewStore()
|
||||
}
|
||||
|
||||
// Config 配置
|
||||
type Config struct {
|
||||
Database struct {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package intimate
|
||||
|
||||
import "testing"
|
||||
|
||||
|
|
1
go.sum
1
go.sum
|
@ -143,6 +143,7 @@ google.golang.org/genproto v0.0.0-20190626174449-989357319d63/go.mod h1:z3L6/3dT
|
|||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
|
15
main.go
15
main.go
|
@ -1,15 +0,0 @@
|
|||
package main
|
||||
|
||||
// InitConfig 初始化配置加载 config.yaml(yml)
|
||||
var InitConfig *Config
|
||||
|
||||
func init() {
|
||||
InitConfig = &Config{}
|
||||
InitConfig.Load()
|
||||
|
||||
storeOpenrec = NewStore()
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package intimate
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
1
tasks/openrec/.gitignore
vendored
Normal file
1
tasks/openrec/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
openrec
|
1
tasks/openrec/config.yaml
Symbolic link
1
tasks/openrec/config.yaml
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../config.yaml
|
8
tasks/openrec/main.go
Normal file
8
tasks/openrec/main.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import "github.com/474420502/hunter"
|
||||
|
||||
func main() {
|
||||
ht := hunter.NewHunter(openrecRanking)
|
||||
ht.Execute()
|
||||
}
|
|
@ -6,14 +6,16 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"intimate"
|
||||
|
||||
"github.com/474420502/hunter"
|
||||
)
|
||||
|
||||
var targetTypeRanking = "openrec_ranking"
|
||||
var openrecRanking *OpenrecRanking
|
||||
|
||||
// storeOpenrec 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql
|
||||
var storeOpenrec *Store
|
||||
// store 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql
|
||||
var store *intimate.Store = intimate.NewStore()
|
||||
|
||||
func init() {
|
||||
|
||||
|
@ -30,6 +32,7 @@ func init() {
|
|||
-H 'accept-language: zh-CN,zh;q=0.9' \
|
||||
-H 'if-none-match: W/"25edb-aUYBdmLqZcr6DW4ZWKX9r2aqolg"' \
|
||||
--compressed`
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -162,8 +165,7 @@ func (or *OpenrecRanking) Execute(cxt *hunter.TaskContext) {
|
|||
|
||||
data := &SourceOpenrec{}
|
||||
content := resp.Content()
|
||||
log.Println(len(content))
|
||||
if len(content) <= 300 {
|
||||
if len(content) <= 200 {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -180,7 +182,7 @@ func (or *OpenrecRanking) Execute(cxt *hunter.TaskContext) {
|
|||
|
||||
data.SetErrorMsg(errorMsg)
|
||||
data.SetOperator(10000)
|
||||
storeOpenrec.Save(data)
|
||||
store.Save(data)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -189,7 +191,7 @@ func (or *OpenrecRanking) Execute(cxt *hunter.TaskContext) {
|
|||
wf.SetQuery(querys)
|
||||
|
||||
data.SetErrorMsg(errorMsg)
|
||||
storeOpenrec.Save(data)
|
||||
store.Save(data)
|
||||
|
||||
time.Sleep(time.Second * 2)
|
||||
}
|
|
@ -55,3 +55,8 @@ func TestRanking(t *testing.T) {
|
|||
ht.SetShare("test", t)
|
||||
ht.Execute()
|
||||
}
|
||||
|
||||
func TestRankingInsert(t *testing.T) {
|
||||
ht := hunter.NewHunter(openrecRanking)
|
||||
ht.Execute()
|
||||
}
|
Loading…
Reference in New Issue
Block a user