|
@@ -64,6 +64,11 @@ func AutoTask() error {
|
|
|
log.Println("service [UpdateProjectTaskWeiBoLinkData] error:", err9)
|
|
|
return err9
|
|
|
}
|
|
|
+ _, err10 := c.AddFunc(spec, UpdateLocalTaskWeiBoLinkData)
|
|
|
+ if err10 != nil {
|
|
|
+ log.Println("service [UpdateProjectTaskWeiBoLinkData] error:", err10)
|
|
|
+ return err10
|
|
|
+ }
|
|
|
fmt.Println(spec)
|
|
|
c.Start()
|
|
|
return nil
|
|
@@ -284,3 +289,58 @@ func UpdateProjectTaskWeiBoLinkData() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// UpdateLocalTaskWeiBoLinkData 定时拉取微博平台,本地生活子任务链接数据
|
|
|
+func UpdateLocalTaskWeiBoLinkData() {
|
|
|
+
|
|
|
+ log.Println("UpdateLocalTaskWeiBoLinkData is running ,Time :", time.Now())
|
|
|
+
|
|
|
+ // 1. 符合条件的local
|
|
|
+ ctx := context.Background()
|
|
|
+ localIdList, localIdListTotal, localIdListErr := db.GetLocalIdList(ctx, 8, 3)
|
|
|
+ if localIdListErr != nil {
|
|
|
+ log.Println("GetLocalIdList error : ", localIdListErr)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 符合条件的task
|
|
|
+ if localIdList != nil && localIdListTotal != 0 {
|
|
|
+ for _, localId := range localIdList {
|
|
|
+ taskIdList, taskIdTotal, taskIdErr := db.GetLocalTaskIdList(ctx, localId)
|
|
|
+ if taskIdErr != nil {
|
|
|
+ log.Println("UpdateLocalTaskWeiBoLinkData 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.LocalTaskLinkStatistic{
|
|
|
+ LocalId: localId,
|
|
|
+ TaskId: taskId,
|
|
|
+ PlatformId: 3,
|
|
|
+ VoteCount: like,
|
|
|
+ CommitCount: comment,
|
|
|
+ CollectionCount: collect,
|
|
|
+ ViewCount: share,
|
|
|
+ }
|
|
|
+ createErr := db.CreateLocalTaskLinkStatistic(ctx, &createData)
|
|
|
+ if createErr != nil {
|
|
|
+ log.Println("CreateProjectTaskLinkStatistic error : ", createErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|