|
@@ -26,8 +26,9 @@ type (
|
|
BaseUserId int64
|
|
BaseUserId int64
|
|
|
|
|
|
AnalysisRes struct {
|
|
AnalysisRes struct {
|
|
- Name, Code string //标签名字
|
|
|
|
- Data map[BaseUserId]bool //数据
|
|
|
|
|
|
+ Name, Code string //标签名字
|
|
|
|
+ Data map[BaseUserId]bool //数据
|
|
|
|
+ SaveOldData bool //累计统计时需要设置为true 是否保留旧数据
|
|
}
|
|
}
|
|
)
|
|
)
|
|
|
|
|
|
@@ -57,13 +58,15 @@ func (ar *AnalysisRes) UpdateTag(ctx context.Context) {
|
|
}
|
|
}
|
|
|
|
|
|
if len(updateBatch) == 0 {
|
|
if len(updateBatch) == 0 {
|
|
- execSql := fmt.Sprintf(`ALTER TABLE dwd_d_tag UPDATE bitobj = bitmapBuild([toUInt64(0)]) WHERE code = '%v';`, ar.Code)
|
|
|
|
- if _, err := g.DB().Exec(ctx, execSql); err != nil {
|
|
|
|
- g.Log().Errorf(ctx, "更新标签%s 滞空异常 %v", ar.Code, err)
|
|
|
|
|
|
+ if !ar.SaveOldData {
|
|
|
|
+ execSql := fmt.Sprintf(`ALTER TABLE dwd_d_tag UPDATE bitobj = bitmapBuild([toUInt64(0)]) WHERE code = '%v';`, ar.Code)
|
|
|
|
+ if _, err := g.DB().Exec(ctx, execSql); err != nil {
|
|
|
|
+ g.Log().Errorf(ctx, "更新标签%s 滞空异常 %v", ar.Code, err)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
for i, batch := range updateBatch {
|
|
for i, batch := range updateBatch {
|
|
- if i == 0 {
|
|
|
|
|
|
+ if i == 0 && !ar.SaveOldData {
|
|
execSql := fmt.Sprintf(`ALTER TABLE dwd_d_tag UPDATE bitobj = bitmapBuild([%v]) WHERE code = '%v';`, strings.Join(batch, ","), ar.Code)
|
|
execSql := fmt.Sprintf(`ALTER TABLE dwd_d_tag UPDATE bitobj = bitmapBuild([%v]) WHERE code = '%v';`, strings.Join(batch, ","), ar.Code)
|
|
if _, err := g.DB().Exec(ctx, execSql); err != nil {
|
|
if _, err := g.DB().Exec(ctx, execSql); err != nil {
|
|
g.Log().Errorf(ctx, "更新标签%s [%d]异常 %v", ar.Code, i, err)
|
|
g.Log().Errorf(ctx, "更新标签%s [%d]异常 %v", ar.Code, i, err)
|