From ebbdc74823860cf4f4a30e491bcc63c9af4d99c1 Mon Sep 17 00:00:00 2001 From: ikalugin Date: Mon, 11 Nov 2024 16:05:55 +0100 Subject: [PATCH] fix(#5686): fix pbh_origin_icon for pbh without tstop + fix delete /entity-pbehaviors endpoint for pbh without tstop --- community/go-engines-community/lib/api/pbehavior/store.go | 5 ++++- .../lib/api/serviceweather/mongo_query.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/community/go-engines-community/lib/api/pbehavior/store.go b/community/go-engines-community/lib/api/pbehavior/store.go index 2ed605c64a..d9e3f6712f 100644 --- a/community/go-engines-community/lib/api/pbehavior/store.go +++ b/community/go-engines-community/lib/api/pbehavior/store.go @@ -667,7 +667,10 @@ func (s *store) EntityDelete(ctx context.Context, r BulkEntityDeleteRequestItem) "entity": r.Entity, "origin": r.Origin, "tstart": bson.M{"$lte": now}, - "tstop": bson.M{"$gte": now}, + "$or": bson.A{ + bson.M{"tstop": nil}, + bson.M{"tstop": bson.M{"$gte": now}}, + }, }, options.FindOneAndDelete().SetProjection(bson.M{"_id": 1})). Decode(&pbh) if err != nil { diff --git a/community/go-engines-community/lib/api/serviceweather/mongo_query.go b/community/go-engines-community/lib/api/serviceweather/mongo_query.go index 16beb35a32..100412bfa9 100644 --- a/community/go-engines-community/lib/api/serviceweather/mongo_query.go +++ b/community/go-engines-community/lib/api/serviceweather/mongo_query.go @@ -616,7 +616,10 @@ func getPbhOriginLookup(origin string, now datetime.CpsTime) []bson.M { {"$match": bson.M{ "origin": origin, "tstart": bson.M{"$lte": now}, - "tstop": bson.M{"$gte": now}, + "$or": bson.A{ + bson.M{"tstop": nil}, + bson.M{"tstop": bson.M{"$gte": now}}, + }, }}, {"$limit": 1}, },