@@ -120,12 +120,26 @@ func (d *DatumRepository) EnsureIndexes() error {
120120 Options : options .Index ().
121121 SetName ("UploadId" ),
122122 },
123+ // {
124+ // Keys: bson.D{
125+ // {Key: "_userId", Value: 1},
126+ // {Key: "deviceId", Value: 1},
127+ // {Key: "type", Value: 1},
128+ // {Key: "_active", Value: 1},
129+ // {Key: "_deduplicator.hash", Value: 1},
130+ // },
131+ // Options: options.Index().
132+ // SetPartialFilterExpression(bson.D{
133+ // {Key: "_active", Value: true},
134+ // {Key: "_deduplicator.hash", Value: bson.D{{Key: "$exists", Value: true}}},
135+ // {Key: "deviceId", Value: bson.D{{Key: "$exists", Value: true}}},
136+ // }).
137+ // SetName("DeduplicatorHash"),
138+ // },
123139 {
124140 Keys : bson.D {
125141 {Key : "_userId" , Value : 1 },
126142 {Key : "deviceId" , Value : 1 },
127- {Key : "type" , Value : 1 },
128- {Key : "_active" , Value : 1 },
129143 {Key : "_deduplicator.hash" , Value : 1 },
130144 },
131145 Options : options .Index ().
@@ -134,7 +148,7 @@ func (d *DatumRepository) EnsureIndexes() error {
134148 {Key : "_deduplicator.hash" , Value : bson.D {{Key : "$exists" , Value : true }}},
135149 {Key : "deviceId" , Value : bson.D {{Key : "$exists" , Value : true }}},
136150 }).
137- SetName ("DeduplicatorHash " ),
151+ SetName ("DeduplicatorHashNoType " ),
138152 },
139153 })
140154}
@@ -228,7 +242,7 @@ func (d *DatumRepository) ArchiveDataSetData(ctx context.Context, dataSet *uploa
228242 if err := validateDataSet (dataSet ); err != nil {
229243 return err
230244 }
231- selector , _ , err := validateAndTranslateSelectors (selectors )
245+ selector , hasOriginID , err := validateAndTranslateSelectors (selectors )
232246 if err != nil {
233247 return err
234248 }
@@ -251,7 +265,11 @@ func (d *DatumRepository) ArchiveDataSetData(ctx context.Context, dataSet *uploa
251265 "archivedDatasetId" : 1 ,
252266 "modifiedUserId" : 1 ,
253267 }
254- changeInfo , err := d .UpdateMany (ctx , selector , d .ConstructUpdate (set , unset ))
268+ opts := options .Update ()
269+ if hasOriginID {
270+ opts .SetHint ("UserIdOriginId" )
271+ }
272+ changeInfo , err := d .UpdateMany (ctx , selector , d .ConstructUpdate (set , unset ), opts )
255273 if err != nil {
256274 logger .WithError (err ).Error ("Unable to archive data set data" )
257275 return fmt .Errorf ("unable to archive data set data: %w" , err )
@@ -405,7 +423,7 @@ func (d *DatumRepository) ArchiveDeviceDataUsingHashesFromDataSet(ctx context.Co
405423 "modifiedTime" : timestamp ,
406424 }
407425 unset := bson.M {}
408- opts := options .Update ().SetHint ("DeduplicatorHash " )
426+ opts := options .Update ().SetHint ("DeduplicatorHashNoType " )
409427 updateInfo , err = d .UpdateMany (ctx , selector , d .ConstructUpdate (set , unset ), opts )
410428 }
411429
0 commit comments