From 0af33ba58b8c8a71c09cfa32c7e582f2a2947c82 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 24 May 2010 18:52:01 +0200 Subject: [PATCH] check just facets available in current dataset This allows us to use facet from other dataset, and quickly filter it just to values which are available in current set. --- lib/MojoFacets/Data.pm | 2 +- templates/data/facet.html.ep | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index 5559fd7..b4f1258 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -547,7 +547,7 @@ sub facet { } elsif ( $sort =~ m/d/i ) { $numeric ? $b <=> $a : lc $b cmp lc $a; } elsif ( $sort =~ m/c/i ) { - $facet->{$b} <=> $facet->{$a}; + ( $facet->{$b} || -1 ) <=> ( $facet->{$a} || -1 ) } else { warn "unknown sort: $sort"; $a cmp $b; diff --git a/templates/data/facet.html.ep b/templates/data/facet.html.ep index d073ba9..5c907e0 100644 --- a/templates/data/facet.html.ep +++ b/templates/data/facet.html.ep @@ -26,10 +26,12 @@ % foreach my $n ( @$facet_names ) {
  • +% if ( defined $facet->{$n} ) { <%= $facet->{$n} %> +% } % } -- 2.20.1