wkyuer 4 bulan lalu
induk
melakukan
52c38f816b
2 mengubah file dengan 15 tambahan dan 17 penghapusan
  1. 14 16
      userSign/main.go
  2. 1 1
      userSign/userAnalysis/jobCklogs.go

+ 14 - 16
userSign/main.go

@@ -6,6 +6,7 @@ import (
 	_ "github.com/gogf/gf/contrib/drivers/clickhouse/v2"
 	_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
 	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/os/gcron"
 	"github.com/gogf/gf/v2/os/gctx"
 	"time"
 	"workTasks/userSign/userAnalysis"
@@ -14,21 +15,21 @@ import (
 
 func main() {
 	ctx := gctx.New()
-	//runOnce(context.TODO())
-	//if e := userTag.BaseUserTag(); e != nil {
-	//	g.Log().Errorf(ctx, "BaseUserTag 异常", e)
-	//}
-
-	//_, err := gcron.Add(gctx.New(), g.Cfg().MustGet(ctx, "runCron", "# 0 2 * * *").String(), func(ctx context.Context) {
 	runOnce(context.TODO())
 	if e := userTag.BaseUserTag(); e != nil {
 		g.Log().Errorf(ctx, "BaseUserTag 异常", e)
 	}
-	//}, "userSign")
-	//if err != nil {
-	//	panic(err)
-	//}
-	//select {}
+
+	_, err := gcron.Add(gctx.New(), g.Cfg().MustGet(ctx, "runCron", "# 0 2 * * *").String(), func(ctx context.Context) {
+		runOnce(context.TODO())
+		if e := userTag.BaseUserTag(); e != nil {
+			g.Log().Errorf(ctx, "BaseUserTag 异常", e)
+		}
+	}, "userSign")
+	if err != nil {
+		panic(err)
+	}
+	select {}
 }
 
 func runOnce(ctx context.Context) {
@@ -85,11 +86,8 @@ func runOnce(ctx context.Context) {
 		allRes = append(allRes, &userAnalysis.AnalysisRes{Name: "访问过剑鱼产品", Code: "visited", Data: res, SaveOldData: true})
 	}
 	// 访问过指定页面
-	res, err := manager.GetVisitUserAnalysis(ctx, nowTime.AddDate(0, 0, -45))
-	if err != nil {
-		g.Log().Panicf(ctx, err.Error())
-	}
-	if err == nil && len(res) > 0 {
+
+	if res, err := manager.GetVisitUserAnalysis(ctx, nowTime.AddDate(0, 0, -45)); err == nil && len(res) > 0 {
 		for _, t := range res {
 			allRes = append(allRes, t)
 		}

+ 1 - 1
userSign/userAnalysis/jobCklogs.go

@@ -12,7 +12,7 @@ func (ua *UserAnalysis) GetVisitUserAnalysis(ctx context.Context, t time.Time) (
 	var (
 		visitedVipBuyPage = map[BaseUserId]bool{}
 	)
-	res, err := g.DB().Query(ctx, "SELECT user_id,count(*) as total  FROM dwd_f_personnel_behavior WHERE `date` > ? and user_id!='' AND (url like '%jy_mobile/order/create/svip%' or url like '%/swordfish/page_big_pc/free/svip/buy%') group by user_id order BY total desc", t.Format(time.DateTime))
+	res, err := g.DB("ckLogs").Query(ctx, "SELECT user_id,count(*) as total  FROM dwd_f_personnel_behavior WHERE `date` > ? and user_id!='' AND (url like '%jy_mobile/order/create/svip%' or url like '%/swordfish/page_big_pc/free/svip/buy%') group by user_id order BY total desc", t.Format(time.DateTime))
 	if err != nil {
 		return nil, errors.Wrap(err, "查询超级订阅购买页访问数据异常")
 	}