Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
refactor: optimize heartbeats MongoDB indexes
Acho Arnoldd85234a38cbe
diff --git a/api/pkg/repositories/mongodb.go b/api/pkg/repositories/mongodb.goindex f2f65ea9..bd6f12be 100644--- a/api/pkg/repositories/mongodb.go+++ b/api/pkg/repositories/mongodb.go@@ -106,9 +106,14 @@ func parseMongoDBName(uri string) (string, error) {func createMongoIndexes(ctx context.Context, db *mongo.Database) error {// Heartbeats indexesheartbeatsCol := db.Collection(collectionHeartbeats)++ // TODO: Remove this block after deploying once — old indexes will have been dropped in production.+ for _, name := range []string{"owner_1_timestamp_-1", "user_id_1"} {+ _ = heartbeatsCol.Indexes().DropOne(ctx, name)+ }+_, err := heartbeatsCol.Indexes().CreateMany(ctx, []mongo.IndexModel{- {Keys: bson.D{{"owner", 1}, {"timestamp", -1}}},- {Keys: bson.D{{"user_id", 1}}},+ {Keys: bson.D{{"user_id", 1}, {"owner", 1}, {"timestamp", -1}}},})if err != nil {return stacktrace.Propagate(err, "cannot create indexes on heartbeats collection")