@@ -485,6 +485,9 @@ export class FulfillmentProductService
485
485
subject ?: Subject ,
486
486
context ?: any ,
487
487
) : Promise < FulfillmentCourierListResponse > {
488
+ const ids = [ ...new Set (
489
+ query . preferences ?. courier_ids ?. map ( id => id ) ?? [ ]
490
+ ) . values ( ) ] ;
488
491
const call = ReadRequest . fromPartial ( {
489
492
filters : [
490
493
{
@@ -494,13 +497,15 @@ export class FulfillmentProductService
494
497
operation : Filter_Operation . in ,
495
498
value : query . shop_id
496
499
} ,
497
- ...( query . preferences ?. courier_ids ?. map (
498
- id => ( {
500
+ ...(
501
+ ids ?. length ?
502
+ [ {
499
503
field : '_key' , // _key is faster
500
- operation : Filter_Operation . eq ,
501
- value : id ,
502
- } )
503
- ) . filter ( item => ! ! item ) ?? [ ] )
504
+ operation : Filter_Operation . in ,
505
+ type : Filter_ValueType . ARRAY ,
506
+ value : JSON . stringify ( ids ) ,
507
+ } ] : [ ]
508
+ )
504
509
] ,
505
510
operator : FilterOp_Operator . and
506
511
}
@@ -551,9 +556,21 @@ export class FulfillmentProductService
551
556
throw this . operation_status_codes . COURIERS_NOT_FOUND ;
552
557
}
553
558
559
+ const ids = [ ...new Set (
560
+ query . preferences ?. courier_ids ?. map ( id => id ) ?? [ ]
561
+ ) . values ( ) ] ;
554
562
const call = ReadRequest . fromPartial ( {
555
563
filters : [ {
556
564
filters : [
565
+ ...(
566
+ ids ?. length ?
567
+ [ {
568
+ field : '_key' , // _key is faster
569
+ operation : Filter_Operation . in ,
570
+ type : Filter_ValueType . ARRAY ,
571
+ value : JSON . stringify ( ids ) ,
572
+ } ] : [ ]
573
+ ) ,
557
574
{
558
575
field : 'courier_id' ,
559
576
operation : Filter_Operation . in ,
0 commit comments