(plugin) apps::protocols::http - mode collection add filter option for count method (#3792)
This commit is contained in:
parent
195cc1a69a
commit
0a51a150dc
|
@ -1275,7 +1275,19 @@ sub exec_func_count {
|
|||
my $data = $self->get_special_variable_value(%$result);
|
||||
my $value = 0;
|
||||
if (defined($data)) {
|
||||
$value = scalar(keys %$data);
|
||||
if (defined($options{filter}) && $options{filter} ne '') {
|
||||
my $count = 0;
|
||||
foreach my $instance (keys %$data) {
|
||||
my $values = $self->{expand};
|
||||
foreach my $label (keys %{$data->{$instance}}) {
|
||||
$values->{'src.' . $label} = $data->{$instance}->{$label};
|
||||
}
|
||||
$count++ unless ($self->check_filter(filter => $options{filter}, values => $values));
|
||||
}
|
||||
$value = $count;
|
||||
} else {
|
||||
$value = scalar(keys %$data);
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($options{save}) && $options{save} ne '') {
|
||||
|
@ -1501,7 +1513,7 @@ sub check_filter {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
return 0 if (!defined($options{filter}) || $options{filter} eq '');
|
||||
our $expand = $self->{expand};
|
||||
our $expand = $options{values};
|
||||
$options{filter} =~ s/%\(([a-zA-Z0-9\._:]+?)\)/\$expand->{'$1'}/g;
|
||||
my $result = $self->{safe}->reval("$options{filter}");
|
||||
if ($@) {
|
||||
|
@ -1585,7 +1597,7 @@ sub add_selection {
|
|||
$self->set_expand_table(section => "selection > $i > expand_table", expand => $_->{expand_table});
|
||||
$self->set_expand(section => "selection > $i > expand", expand => $_->{expand});
|
||||
$self->set_functions(section => "selection > $i > functions", functions => $_->{functions}, position => 'after_expand', default => 1);
|
||||
next if ($self->check_filter(filter => $_->{filter}));
|
||||
next if ($self->check_filter(filter => $_->{filter}, values => $self->{expand}));
|
||||
next if ($self->check_filter_option());
|
||||
$config->{unknown} = $self->prepare_variables(section => "selection > $i > unknown", value => $_->{unknown});
|
||||
$config->{warning} = $self->prepare_variables(section => "selection > $i > warning", value => $_->{warning});
|
||||
|
@ -1630,7 +1642,7 @@ sub add_selection_loop {
|
|||
$self->set_expand_table(section => "selection_loop > $i > expand_table", expand => $_->{expand_table});
|
||||
$self->set_expand(section => "selection_loop > $i > expand", expand => $_->{expand});
|
||||
$self->set_functions(section => "selection_loop > $i > functions", functions => $_->{functions}, position => 'after_expand', default => 1);
|
||||
next if ($self->check_filter(filter => $_->{filter}));
|
||||
next if ($self->check_filter(filter => $_->{filter}, values => $self->{expand}));
|
||||
next if ($self->check_filter_option());
|
||||
$config->{unknown} = $self->prepare_variables(section => "selection_loop > $i > unknown", value => $_->{unknown});
|
||||
$config->{warning} = $self->prepare_variables(section => "selection_loop > $i > warning", value => $_->{warning});
|
||||
|
|
|
@ -1042,7 +1042,19 @@ sub exec_func_count {
|
|||
my $data = $self->get_special_variable_value(%$result);
|
||||
my $value = 0;
|
||||
if (defined($data)) {
|
||||
$value = scalar(keys %$data);
|
||||
if (defined($options{filter}) && $options{filter} ne '') {
|
||||
my $count = 0;
|
||||
foreach my $instance (keys %$data) {
|
||||
my $values = $self->{expand};
|
||||
foreach my $label (keys %{$data->{$instance}}) {
|
||||
$values->{'src.' . $label} = $data->{$instance}->{$label};
|
||||
}
|
||||
$count++ unless ($self->check_filter(filter => $options{filter}, values => $values));
|
||||
}
|
||||
$value = $count;
|
||||
} else {
|
||||
$value = scalar(keys %$data);
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($options{save}) && $options{save} ne '') {
|
||||
|
@ -1256,7 +1268,7 @@ sub check_filter {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
return 0 if (!defined($options{filter}) || $options{filter} eq '');
|
||||
our $expand = $self->{expand};
|
||||
our $expand = $options{values};
|
||||
$options{filter} =~ s/%\(([a-zA-Z0-9\._:]+?)\)/\$expand->{'$1'}/g;
|
||||
my $result = $self->{safe}->reval("$options{filter}");
|
||||
if ($@) {
|
||||
|
@ -1340,7 +1352,7 @@ sub add_selection {
|
|||
$self->set_expand_table(section => "selection > $i > expand_table", expand => $_->{expand_table});
|
||||
$self->set_expand(section => "selection > $i > expand", expand => $_->{expand});
|
||||
$self->set_functions(section => "selection > $i > functions", functions => $_->{functions}, position => 'after_expand', default => 1);
|
||||
next if ($self->check_filter(filter => $_->{filter}));
|
||||
next if ($self->check_filter(filter => $_->{filter}, values => $self->{expand}));
|
||||
next if ($self->check_filter_option());
|
||||
$config->{unknown} = $self->prepare_variables(section => "selection > $i > unknown", value => $_->{unknown});
|
||||
$config->{warning} = $self->prepare_variables(section => "selection > $i > warning", value => $_->{warning});
|
||||
|
@ -1385,7 +1397,7 @@ sub add_selection_loop {
|
|||
$self->set_expand_table(section => "selection_loop > $i > expand_table", expand => $_->{expand_table});
|
||||
$self->set_expand(section => "selection_loop > $i > expand", expand => $_->{expand});
|
||||
$self->set_functions(section => "selection_loop > $i > functions", functions => $_->{functions}, position => 'after_expand', default => 1);
|
||||
next if ($self->check_filter(filter => $_->{filter}));
|
||||
next if ($self->check_filter(filter => $_->{filter}, values => $self->{expand}));
|
||||
next if ($self->check_filter_option());
|
||||
$config->{unknown} = $self->prepare_variables(section => "selection_loop > $i > unknown", value => $_->{unknown});
|
||||
$config->{warning} = $self->prepare_variables(section => "selection_loop > $i > warning", value => $_->{warning});
|
||||
|
|
Loading…
Reference in New Issue