|
@@ -59,6 +59,11 @@ func AutoTask() error {
|
|
|
log.Println("service [UpdateLocalTaskRedBookLinkData] error:", err8)
|
|
|
return err8
|
|
|
}
|
|
|
+ _, err9 := c.AddFunc(spec, UpdateProjectTaskWeiBoLinkData)
|
|
|
+ if err9 != nil {
|
|
|
+ log.Println("service [UpdateProjectTaskWeiBoLinkData] error:", err9)
|
|
|
+ return err9
|
|
|
+ }
|
|
|
fmt.Println(spec)
|
|
|
c.Start()
|
|
|
return nil
|
|
@@ -224,3 +229,58 @@ func UpdateLocalTaskRedBookLinkData() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// UpdateProjectTaskWeiBoLinkData 定时拉取微博平台,种草子任务链接数据
|
|
|
+func UpdateProjectTaskWeiBoLinkData() {
|
|
|
+
|
|
|
+ log.Println("UpdateProjectTaskWeiBoLinkData is running ,Time :", time.Now())
|
|
|
+
|
|
|
+ // 1. 符合条件的project
|
|
|
+ ctx := context.Background()
|
|
|
+ projectIdList, projectIdListTotal, projectIdListErr := db.GetProjectIdList(ctx, 8, 3)
|
|
|
+ if projectIdListErr != nil {
|
|
|
+ log.Println("GetProjectIdList error : ", projectIdListErr)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 符合条件的task
|
|
|
+ if projectIdList != nil && projectIdListTotal != 0 {
|
|
|
+ for _, projectId := range projectIdList {
|
|
|
+ taskIdList, taskIdTotal, taskIdErr := db.GetProjectTaskIdList(ctx, projectId)
|
|
|
+ if taskIdErr != nil {
|
|
|
+ log.Println("GetProjectTaskIdList error : ", taskIdErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if taskIdList != nil && taskIdTotal != 0 {
|
|
|
+ for _, taskId := range taskIdList {
|
|
|
+ linkInfo, linkErr := db.GetProjectTaskLinkInfo(ctx, taskId, 1)
|
|
|
+ if linkErr != nil {
|
|
|
+ log.Println("GetProjectTaskLinkInfo error : ", linkErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if linkInfo != "" {
|
|
|
+ like, comment, collect, share, moreApiErr := GetWeiBoLinkDetail(ctx, linkInfo)
|
|
|
+ if moreApiErr != nil {
|
|
|
+ log.Println("GetWeiBoLinkDetail error : ", moreApiErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createData := gorm_model.ProjectTaskLinkStatistic{
|
|
|
+ ProjectId: projectId,
|
|
|
+ TaskId: taskId,
|
|
|
+ PlatformId: 3,
|
|
|
+ VoteCount: like,
|
|
|
+ CommitCount: comment,
|
|
|
+ CollectionCount: collect,
|
|
|
+ ViewCount: share,
|
|
|
+ }
|
|
|
+ createErr := db.CreateProjectTaskLinkStatistic(ctx, &createData)
|
|
|
+ if createErr != nil {
|
|
|
+ log.Println("CreateProjectTaskLinkStatistic error : ", createErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|