@@ -92,16 +92,16 @@ func (d *DatumRepository) EnsureIndexes() error {
9292 },
9393 }),
9494 },
95- {
96- Keys : bson.D {
97- {Key : "origin.id" , Value : 1 },
98- {Key : "type" , Value : 1 },
99- {Key : "deletedTime" , Value : - 1 },
100- {Key : "_active" , Value : 1 },
101- },
102- Options : options .Index ().
103- SetName ("OriginId" ),
104- },
95+ // {
96+ // Keys: bson.D{
97+ // {Key: "origin.id", Value: 1},
98+ // {Key: "type", Value: 1},
99+ // {Key: "deletedTime", Value: -1},
100+ // {Key: "_active", Value: 1},
101+ // },
102+ // Options: options.Index().
103+ // SetName("OriginId"),
104+ // },
105105 {
106106 Keys : bson.D {
107107 {Key : "_userId" , Value : 1 },
@@ -125,12 +125,26 @@ func (d *DatumRepository) EnsureIndexes() error {
125125 Options : options .Index ().
126126 SetName ("UploadId" ),
127127 },
128+ // {
129+ // Keys: bson.D{
130+ // {Key: "_userId", Value: 1},
131+ // {Key: "deviceId", Value: 1},
132+ // {Key: "type", Value: 1},
133+ // {Key: "_active", Value: 1},
134+ // {Key: "_deduplicator.hash", Value: 1},
135+ // },
136+ // Options: options.Index().
137+ // SetPartialFilterExpression(bson.D{
138+ // {Key: "_active", Value: true},
139+ // {Key: "_deduplicator.hash", Value: bson.D{{Key: "$exists", Value: true}}},
140+ // {Key: "deviceId", Value: bson.D{{Key: "$exists", Value: true}}},
141+ // }).
142+ // SetName("DeduplicatorHash"),
143+ // },
128144 {
129145 Keys : bson.D {
130146 {Key : "_userId" , Value : 1 },
131147 {Key : "deviceId" , Value : 1 },
132- {Key : "type" , Value : 1 },
133- {Key : "_active" , Value : 1 },
134148 {Key : "_deduplicator.hash" , Value : 1 },
135149 },
136150 Options : options .Index ().
@@ -139,7 +153,7 @@ func (d *DatumRepository) EnsureIndexes() error {
139153 {Key : "_deduplicator.hash" , Value : bson.D {{Key : "$exists" , Value : true }}},
140154 {Key : "deviceId" , Value : bson.D {{Key : "$exists" , Value : true }}},
141155 }).
142- SetName ("DeduplicatorHash " ),
156+ SetName ("DeduplicatorHashNoType " ),
143157 },
144158 })
145159}
@@ -233,7 +247,7 @@ func (d *DatumRepository) ArchiveDataSetData(ctx context.Context, dataSet *uploa
233247 if err := validateDataSet (dataSet ); err != nil {
234248 return err
235249 }
236- selector , _ , err := validateAndTranslateSelectors (selectors )
250+ selector , hasOriginID , err := validateAndTranslateSelectors (selectors )
237251 if err != nil {
238252 return err
239253 }
@@ -256,7 +270,11 @@ func (d *DatumRepository) ArchiveDataSetData(ctx context.Context, dataSet *uploa
256270 "archivedDatasetId" : 1 ,
257271 "modifiedUserId" : 1 ,
258272 }
259- changeInfo , err := d .UpdateMany (ctx , selector , d .ConstructUpdate (set , unset ))
273+ opts := options .Update ()
274+ if hasOriginID {
275+ opts .SetHint ("UserIdOriginId" )
276+ }
277+ changeInfo , err := d .UpdateMany (ctx , selector , d .ConstructUpdate (set , unset ), opts )
260278 if err != nil {
261279 logger .WithError (err ).Error ("Unable to archive data set data" )
262280 return fmt .Errorf ("unable to archive data set data: %w" , err )
@@ -299,7 +317,7 @@ func (d *DatumRepository) DeleteDataSetData(ctx context.Context, dataSet *upload
299317 }
300318 opts := options .Update ()
301319 if hasOriginID {
302- opts .SetHint ("OriginId " )
320+ opts .SetHint ("UserIdOriginId " )
303321 }
304322 changeInfo , err := d .UpdateMany (ctx , selector , d .ConstructUpdate (set , unset ), opts )
305323 if err != nil {
@@ -332,7 +350,7 @@ func (d *DatumRepository) DestroyDeletedDataSetData(ctx context.Context, dataSet
332350 selector ["deletedTime" ] = bson.M {"$exists" : true }
333351 opts := options .Delete ()
334352 if hasOriginID {
335- opts .SetHint ("OriginId " )
353+ opts .SetHint ("UserIdOriginId " )
336354 }
337355 changeInfo , err := d .DeleteMany (ctx , selector , opts )
338356 if err != nil {
@@ -410,7 +428,7 @@ func (d *DatumRepository) ArchiveDeviceDataUsingHashesFromDataSet(ctx context.Co
410428 "modifiedTime" : timestamp ,
411429 }
412430 unset := bson.M {}
413- opts := options .Update ().SetHint ("DeduplicatorHash " )
431+ opts := options .Update ().SetHint ("DeduplicatorHashNoType " )
414432 updateInfo , err = d .UpdateMany (ctx , selector , d .ConstructUpdate (set , unset ), opts )
415433 }
416434
0 commit comments