Explorar o código

更新 打标签时间,2小时跑一次

wcc hai 1 ano
pai
achega
3317d5be67
Modificáronse 3 ficheiros con 9 adicións e 5 borrados
  1. 1 0
      website_columns/config.go
  2. 2 1
      website_columns/config.toml
  3. 6 4
      website_columns/main.go

+ 1 - 0
website_columns/config.go

@@ -21,6 +21,7 @@ type MgoConf struct {
 // CronConf 定时任务
 type CronConf struct {
 	Spec    string
+	Spec2   string
 	Start   int
 	End     int
 	Delete  int

+ 2 - 1
website_columns/config.toml

@@ -31,7 +31,8 @@
 
 [cron] ## 定时任务
 #    spec = "0 */1 * * * *"    ## 5分钟执行一次
-    spec = "0 00 01 * * *"     ## 每天01点执行
+    spec = "0 00 05 * * *"     ## 每天5点执行;执行热门数据标签
+    spec2 = "@every 2h"        ## 每2小时,执行一次
     start = 1680749350         ## 表示 comeintime 大于这个值
 #    end = 0                    ## 表示comeintime 小于这个值
 #    delete = -30              ## 删除30天之前的数据

+ 6 - 4
website_columns/main.go

@@ -30,7 +30,9 @@ func main() {
 
 	local, _ := time.LoadLocation("Asia/Shanghai")
 	c := cron.New(cron.WithLocation(local), cron.WithSeconds())
-	eid, err := c.AddFunc(GF.Cron.Spec, dealData)
+	eid, err := c.AddFunc(GF.Cron.Spec, getHot)
+	c.AddFunc(GF.Cron.Spec2, dealData) // 每2小时执行
+
 	if err != nil {
 		log.Info("main", zap.Any("AddFunc err", err))
 	}
@@ -76,7 +78,7 @@ func dealBidding() {
 		//默认 取大于 昨天的数据
 		q = map[string]interface{}{
 			"comeintime": map[string]interface{}{
-				"$gt": time.Date(now.Year(), now.Month(), now.Day()-1, 0, 0, 0, 0, now.Location()).Unix(),
+				"$gt": time.Date(now.Year(), now.Month(), now.Day(), now.Hour()-2, 0, 0, 0, now.Location()).Unix(),
 			},
 		}
 	}
@@ -152,7 +154,7 @@ func dealBidding() {
 	}
 
 	//处理热门标讯数据/热门项目
-	getHot()
+	//getHot()
 	//dealHotDataAll()
 
 	log.Info("dealBidding", zap.Int("over ", count))
@@ -294,7 +296,7 @@ func dealProject() {
 		//默认 取大于 昨天的数据
 		q = map[string]interface{}{
 			"pici": map[string]interface{}{
-				"$gt": time.Date(now.Year(), now.Month(), now.Day()-1, 0, 0, 0, 0, now.Location()).Unix(),
+				"$gt": time.Date(now.Year(), now.Month(), now.Day(), now.Hour()-2, 0, 0, 0, now.Location()).Unix(),
 			},
 		}
 	}