Skip to content

Commit

Permalink
Merge pull request #1921 from afumagalli98/fix-alert-version
Browse files Browse the repository at this point in the history
Fixed alerts API to keep compatibility with mongo version <5
  • Loading branch information
afumagalli98 authored Sep 11, 2024
2 parents 2b2de2d + d527da5 commit 156a004
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions api-service/database/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,16 @@ func (md *MongoDatabase) SearchAlerts(alertFilter alert_filter.Alert) (*dto.Pagi
bson.M{
"$addFields": bson.M{
"daysFromCreation": bson.M{
"$dateDiff": bson.M{
"startDate": "$date",
"endDate": "$$NOW",
"unit": "day",
"$trunc": bson.M{
"$divide": bson.A{
bson.M{
"$subtract": bson.A{
"$$NOW",
"$date",
},
},
24 * 60 * 60 * 1000, // number of milliseconds in a day
},
},
},
},
Expand Down

0 comments on commit 156a004

Please sign in to comment.