fix【【test】预警轨迹更新失败】
https://www.tapd.cn/60863849/bugtrace/bugs/view/1160863849001051295
This commit is contained in:
parent
4207749f56
commit
8f1cd74163
@ -104,6 +104,8 @@ public class ForewarningNotifyService : IForewarningNotifyService, ITransientDep
|
|||||||
addCounter = await RedisHelper.Client.ZAddNxAsync(redisKey, left);
|
addCounter = await RedisHelper.Client.ZAddNxAsync(redisKey, left);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tips:由于预警队列的设计 是悲观的认为所有预警都会在未来发生,实际上预警占真实业务的发生总比应该在少数,所以这里是有优化空间的
|
||||||
|
|
||||||
// 右区间移出预警队列,【只要发生了就移除】
|
// 右区间移出预警队列,【只要发生了就移除】
|
||||||
var right = dels.Select(x => new WarningNotifyCacheEntry(x.ruleId, x.orderId, x.counter)).ToList();
|
var right = dels.Select(x => new WarningNotifyCacheEntry(x.ruleId, x.orderId, x.counter)).ToList();
|
||||||
if (!right.IsNullOrEmpty())
|
if (!right.IsNullOrEmpty())
|
||||||
|
|||||||
@ -46,8 +46,15 @@ public class WarningRecordEsRepository : ElasticSearchContextAbstract<WarningRec
|
|||||||
|
|
||||||
public async Task BulkUpdateAsync(List<(int ruleId, int orderId, int counter)> rules)
|
public async Task BulkUpdateAsync(List<(int ruleId, int orderId, int counter)> rules)
|
||||||
{
|
{
|
||||||
foreach (var rule in rules)
|
foreach (var group in rules.GroupBy(x => new
|
||||||
{
|
{
|
||||||
|
x.ruleId,
|
||||||
|
x.orderId
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
var rule = group.First();
|
||||||
|
|
||||||
|
// 这里需要使用_update_by_query API,因为可能已经发生了多条预警记录,需要一次性更新
|
||||||
var r = await Context.UpdateByQueryAsync<WarningRecordIndex>(u => u
|
var r = await Context.UpdateByQueryAsync<WarningRecordIndex>(u => u
|
||||||
.Index(GlobalConst.TrackWarningRecordIndex)
|
.Index(GlobalConst.TrackWarningRecordIndex)
|
||||||
.Query(q =>
|
.Query(q =>
|
||||||
@ -55,7 +62,7 @@ public class WarningRecordEsRepository : ElasticSearchContextAbstract<WarningRec
|
|||||||
&& q.Term(f => f.OrderId, rule.orderId)
|
&& q.Term(f => f.OrderId, rule.orderId)
|
||||||
)
|
)
|
||||||
.Script(s => s.Source("ctx._source.warningStatus = params.warningStatus")
|
.Script(s => s.Source("ctx._source.warningStatus = params.warningStatus")
|
||||||
.Params(p => p.Add("warningStatus", WarningStatus.Processed))
|
.Params(p => p.Add("warningStatus", (int) WarningStatus.Processed))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user