Skip to content

Commit

Permalink
Item13858: MultiSearchPlugin fails when a sub-search returns no results
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethLavrsen committed Dec 7, 2015
1 parent 18f2628 commit cc87147
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 39 deletions.
73 changes: 37 additions & 36 deletions data/System/MultiSearchPlugin.txt
Expand Up @@ -40,15 +40,15 @@ We would like to create a list of all the engineers that are current having at l
Here is how we can do it

<verbatim>
%MULTISEARCH{
search1="State='Assessed' AND Release='Project X'"
web="Track"
indexfield1="Assignee"
indextype="text"
indexmode="index"
listseparator1=", "
listformat1="[[$web.$topic][$topic]]"
format=" * $indexfield - $list1$n"
%MULTISEARCH{
search1="State='Assessed' AND Release='Project X'"
web="Track"
indexfield1="Assignee"
indextype="text"
indexmode="index"
listseparator1=", "
listformat1="[[$web.$topic][$topic]]"
format=" * $indexfield - $list1$n"
}%
</verbatim>

Expand All @@ -59,21 +59,21 @@ The records have a Business and a State field. The business field can have multi
And finally a footer with the totals.

<verbatim>
%MULTISEARCH{
%MULTISEARCH{
search1="State != 'Rejected'"
search2="State = 'Open'"
search3="State = 'Open' AND Severity = 'High'"
web="Complaints"
search3="State = 'Open' AND Severity = 'High'"
web="Complaints"
indexfield1="Business"
indexfield2="Business"
indexfield3="Business"
indextype="multi"
indexfield3="Business"
indextype="multi"
indexmode="index"
listseparator2=", "
listseparator2=", "
listformat2="[[$web.$topic][$topic]]"
header="| *Business* | *Total* | *Open* | *Open A-level* | *List of Opens* |$n"
header="| *Business* | *Total* | *Open* | *Open A-level* | *List of Opens* |$n"
format="| $indexfield | $nhits1 | $nhits2 | $nhits3 | $list2 |$n"
footer="| | $ntopics1 | $ntopics2 | $ntopics3 | |$n"
footer="| | $ntopics1 | $ntopics2 | $ntopics3 | |$n"
}%
</verbatim>

Expand All @@ -88,25 +88,25 @@ We do not want to count rejected and duplicates in the metric.
We have a field !DateOriginated that gets set when we create the record. And we have a field !DatePerformed which is set the day the issue is resolved.

<verbatim>
%TABLE{name="srrate" columnwidths="150,100,100,200,200"}%
%MULTISEARCH{
search1="(State!='Duplicate' OR State!='Rejected') AND Release='Project X'"
search2="(State='Closed' OR State='Performed') AND Release='Project X'"
web="Track"
indexfield1="DateOriginated"
indexfield2="DatePerformed"
indextype="date"
indexformat="$day $mon $year"
indexmode="interval"
indexstart="01 Jan 2014"
indexend="next Sunday"
indexstep="1 week"
listseparator1=", "
listseparator2=", "
listformat1="[[$web.$topic]]"
listformat2="[[$web.$topic]]"
format="| $indexfield | $ntopics1 | $ntopics2 | $list1 | $list2 |$n"
header="| *Date* | *Opened* | *Resolved* | *Topics* | *Topics* |$n"
%TABLE{name="srrate" columnwidths="150,100,100,200,200"}%
%MULTISEARCH{
search1="(State!='Duplicate' OR State!='Rejected') AND Release='Project X'"
search2="(State='Closed' OR State='Performed') AND Release='Project X'"
web="Track"
indexfield1="DateOriginated"
indexfield2="DatePerformed"
indextype="date"
indexformat="$day $mon $year"
indexmode="interval"
indexstart="01 Jan 2014"
indexend="next Sunday"
indexstep="1 week"
listseparator1=", "
listseparator2=", "
listformat1="[[$web.$topic]]"
listformat2="[[$web.$topic]]"
format="| $indexfield | $ntopics1 | $ntopics2 | $list1 | $list2 |$n"
header="| *Date* | *Opened* | *Resolved* | *Topics* | *Topics* |$n"
}%
</verbatim>

Expand All @@ -124,6 +124,7 @@ The plugin requires the CPAN library Time::ParseDate. Redhat/Centos users can ru
---++ Plugin Info

| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 1.3 (08 Dec 2015) | Fixed a crash of the plugin when a search did not return any results |
| 1.2 (19 Aug 2015) | Added support for topic and excludetopic parameters to improve performance. Added support for the $calc() token to enable simple calculations within the plugin. Added more user input check of the field names |
| 1.1 (18 Aug 2015) | Better handling when using month as relative time (same date in next month instead of fixed number of seconds).<br />More checks on input values to avoid infinite loops<br />Support of the delay parameter when using MULTISEARCH inside a nested SEARCH or FORMAT |
| 1.0 (17 Aug 2015) | Initial release |
Expand Down
7 changes: 4 additions & 3 deletions lib/Foswiki/Plugins/MultiSearchPlugin.pm
Expand Up @@ -37,7 +37,7 @@ use Time::ParseDate (); # For relative dates
# v1.2.1_001 -> v1.2.2 -> v1.2.2_001 -> v1.2.3
# 1.21_001 -> 1.22 -> 1.22_001 -> 1.23
#
our $VERSION = '1.2';
our $VERSION = '1.3';

# $RELEASE is used in the "Find More Extensions" automation in configure.
# It is a manually maintained string used to identify functionality steps.
Expand All @@ -52,7 +52,7 @@ our $VERSION = '1.2';
# It is preferred to keep this compatible with $VERSION. At some future
# date, Foswiki will deprecate RELEASE and use the VERSION string.
#
our $RELEASE = '19 Aug 2015';
our $RELEASE = '08 Dec 2015';

# One line description of the module
our $SHORTDESCRIPTION =
Expand Down Expand Up @@ -455,7 +455,8 @@ sub _MULTISEARCH {
}
}

for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
for ( my $i = 1 ; $i <= $searchCounter ; $i++ ) {
next unless defined $sortedIndexes[$i];
@{$sortedIndexes[$i]} = sort { $a->{indexvalue} <=> $b->{indexvalue} }
@{$sortedIndexes[$i]};
}
Expand Down

0 comments on commit cc87147

Please sign in to comment.