diff --git a/pycsw/ogc/api/records.py b/pycsw/ogc/api/records.py index a3d6a21e4..3ebf0050c 100644 --- a/pycsw/ogc/api/records.py +++ b/pycsw/ogc/api/records.py @@ -31,6 +31,7 @@ import json import logging +from operator import itemgetter import os from urllib.parse import urlencode, quote @@ -1099,6 +1100,8 @@ def get_facets(self, filters=None) -> dict: 'count': fq[1] }) + facets_results[facet]['buckets'].sort(key=itemgetter('count'), reverse=True) + return facets_results diff --git a/pycsw/ogc/api/templates/items.html b/pycsw/ogc/api/templates/items.html index 10c996a25..44b654045 100644 --- a/pycsw/ogc/api/templates/items.html +++ b/pycsw/ogc/api/templates/items.html @@ -58,13 +58,14 @@ for at in attrs.keys() %}{% if at != 'offset' %}{% if attrs[at] not in [None,''] %}{% - if key not in [None,''] and key == at %}&{{ at }}={{ val }}{% + if key not in [None,''] and key == at %}{% + if val != '' %}&{{ at }}={{ val }}{% endif %}{% else %}&{{ at }}={{ attrs[at] }}{% endif %}{% endif %}{% endif %}{% - if key not in attrs.keys() %}&{{ key }}={{ val }}{% endif %}{% - endfor %}{% + endfor %}{% + if key not in attrs.keys() %}&{{ key }}={{ val }}{% endif %}{% endmacro %} {% macro reseturl(key,val) %}{{ @@ -122,18 +123,30 @@ {% if data['facets'] %} {% for facet in data['facets'].keys() %} + {% if data['facets'][facet]['buckets']|length > 0 %}