@@ -33,17 +33,14 @@ func (d *DataSetRepository) EnsureIndexes() error {
3333 Keys : bson.D {
3434 {Key : "_userId" , Value : 1 },
3535 {Key : "_active" , Value : 1 },
36- {Key : "type" , Value : 1 },
3736 {Key : "time" , Value : - 1 },
3837 },
3938 Options : options .Index ().
40- SetBackground (true ).
4139 SetName ("UserIdTypeWeighted_v2" ),
4240 },
4341 {
4442 Keys : bson.D {
4543 {Key : "origin.id" , Value : 1 },
46- {Key : "type" , Value : 1 },
4744 {Key : "deletedTime" , Value : - 1 },
4845 {Key : "_active" , Value : 1 },
4946 },
@@ -59,15 +56,14 @@ func (d *DataSetRepository) EnsureIndexes() error {
5956 SetUnique (true ).
6057 SetName ("UniqueUploadId" ),
6158 },
59+ // TODO UploadId and UniqueUploadId is always unique in deviceDataSets so remove one or the other.
6260 {
6361 Keys : bson.D {
6462 {Key : "uploadId" , Value : 1 },
65- {Key : "type" , Value : 1 },
6663 {Key : "deletedTime" , Value : - 1 },
6764 {Key : "_active" , Value : 1 },
6865 },
6966 Options : options .Index ().
70- SetBackground (true ).
7167 SetName ("UploadId" ),
7268 },
7369 {
@@ -79,14 +75,25 @@ func (d *DataSetRepository) EnsureIndexes() error {
7975 {Key : "_deduplicator.hash" , Value : 1 },
8076 },
8177 Options : options .Index ().
82- SetBackground (true ).
8378 SetPartialFilterExpression (bson.D {
8479 {Key : "_active" , Value : true },
8580 {Key : "_deduplicator.hash" , Value : bson.D {{Key : "$exists" , Value : true }}},
8681 {Key : "deviceId" , Value : bson.D {{Key : "$exists" , Value : true }}},
8782 }).
8883 SetName ("DeduplicatorHash" ),
8984 },
85+ {
86+ Keys : bson.D {
87+ {Key : "_userId" , Value : 1 },
88+ {Key : "_active" , Value : 1 },
89+ {Key : "client.name" , Value : 1 },
90+ },
91+ Options : options .Index ().
92+ SetPartialFilterExpression (bson.D {
93+ {Key : "client.name" , Value : bson.D {{Key : "$exists" , Value : true }}},
94+ }).
95+ SetName ("ClientName" ),
96+ },
9097 })
9198}
9299
@@ -260,7 +267,6 @@ func (d *DataSetRepository) ListUserDataSets(ctx context.Context, userID string,
260267 selector := bson.M {
261268 "_active" : true ,
262269 "_userId" : userID ,
263- "type" : "upload" ,
264270 }
265271 if filter .ClientName != nil {
266272 selector ["client.name" ] = * filter .ClientName
@@ -314,7 +320,6 @@ func (d *DataSetRepository) GetDataSetsForUserByID(ctx context.Context, userID s
314320 selector := bson.M {
315321 "_active" : true ,
316322 "_userId" : userID ,
317- "type" : "upload" ,
318323 }
319324 if ! filter .Deleted {
320325 selector ["deletedTime" ] = bson.M {"$exists" : false }
0 commit comments