From: Dobrica Pavlinusic Date: Mon, 24 May 2010 16:52:01 +0000 (+0200) Subject: check just facets available in current dataset X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=0af33ba58b8c8a71c09cfa32c7e582f2a2947c82;hp=769929cfc8b7186c5283330863aeddd4969c2ed2;p=MojoFacets.git 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. --- 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} %> +% } % }