MT#12083 Use exists optimization for subscriber search by alias

Change-Id: I65a5d4bd02adba1236caba52666e49a82e45908e
changes/73/1373/1
Irina Peshinskaya 11 years ago
parent db75b8222f
commit 81bd0240e3

@ -120,7 +120,7 @@ sub sub_list :Chained('/') :PathPart('subscriber') :CaptureArgs(0) {
{ name => "uuid", search => 1, title => $c->loc('UUID') },
{ name => "status", search => 1, title => $c->loc('Status') },
{ name => "number", search => 1, title => $c->loc('Number'), literal_sql => "concat(primary_number.cc, primary_number.ac, primary_number.sn)",'join' => 'primary_number'},
{ name => "voip_subscriber_aliases_csv.aliases", search => 1, },
{ name => "alias", search => 1, literal_sql => { format => " exists ( select subscriber_id, group_concat(concat(cc,ac,sn)) as aliases from billing.voip_numbers voip_subscriber_aliases_csv where voip_subscriber_aliases_csv.`subscriber_id` = `me`.`id` group by subscriber_id having aliases %s )" } ,'no_column' => 1 },
{ name => "provisioning_voip_subscriber.voip_subscriber_profile.name", search => 1, title => $c->loc('Profile') },
]);
}

@ -29,10 +29,10 @@ sub process {
if($col->{literal_sql}) {
$rs = $rs->search_rs(undef, {
$col->{join} ? ( join => $col->{join} ) : (),
'+select' => { '' => \[$col->{literal_sql}], -as => $col->{accessor}
},
'+as' => [ $col->{accessor} ],
$col->{no_column} ? () : (
'+select' => { '' => \[$col->{literal_sql}], -as => $col->{accessor} },
'+as' => [ $col->{accessor} ],
)
});
} elsif( @parts > 1 ) {
my $join = $parts[$#parts-1];
@ -59,13 +59,21 @@ sub process {
my $name = _get_joined_column_name_($col->{name});
my $stmt;
if($col->{literal_sql}){
#we can't use just accessor because of the count query
$stmt = \[$col->{literal_sql} . " LIKE ?", [ {} => '%'.$searchString.'%'] ];
if(!ref $col->{literal_sql}){
#we can't use just accessor because of the count query
$stmt = \[$col->{literal_sql} . " LIKE ?", [ {} => '%'.$searchString.'%'] ];
}else{
if($col->{literal_sql}->{format}){
$stmt = \[sprintf($col->{literal_sql}->{format}, " LIKE ?"), [ {} => '%'.$searchString.'%'] ];
}
}
}else{
$stmt = { $name => { like => '%'.$searchString.'%' } };
}
push @searchColumns, $stmt;
}
if($stmt){
push @searchColumns, $stmt;
}
}
}
if($searchString && ! $use_rs_cb) {
$rs = $rs->search([@searchColumns]);

Loading…
Cancel
Save