{% macro chart_timeline(timeline, product, period='month') -%}
{% if timeline %} {% set month_width = 650 / timeline | length %} {% if month_width > 5 %} {% set month_width = 5 %} {%endif%} {% set max_count = timeline.most_common(1)[0][1] %}
{% set last = namespace(year=False, bars_this_year=100) %} {% set timeline_items = timeline.items() | sort %} {% for start_time, count in timeline_items %} {% set is_always_shown = loop.index == 1 or loop.index == (timeline_items|length) %} {% if is_always_shown %} {%- if period == 'day' -%}{{- start_time.day | day_ordinal }} {% endif -%} {{-start_time.strftime('%b %Y')-}} {%endif%} {%- if period == 'day' -%}{{- start_time.day | day_ordinal }} {% endif -%} {{-start_time.strftime('%b %Y')-}}
{{ count }} datasets
{% endfor %}
{# We're assuming only 1 control per page, sorry. #} {% endif %}
{%- endmacro %} {% macro query_param_list(fields, prefix="", wide=false, show_nulls=true, show_dicts=true, descriptions=None, fallback_dict={}, dataset=None) -%}
{% for key, value in fields | dictsort if (show_dicts or value is not mapping) recursive %} {# "creation_dt" is excluded, as it's a duplicate of the creation_time field (latter is newer and date typed) #} {% if (show_nulls or (value is not none) or (key in fallback_dict)) and (key != "creation_dt") %} {% set search_link = (dataset and (key in (dataset.type | searchable_fields_keys))) %} {%- if search_link -%} {%- endif -%} {{- key -}} {%- if value is mapping -%} {{- loop(value.items()) -}} {%- elif value is none -%} {%- if key in fallback_dict -%} {% if fallback_dict[key] is not none %} {{- fallback_dict[key] | query_value -}} {% else %} {% endif %} {%- else -%} {%- endif -%} {%- else -%} {{- value | query_value -}} {%- endif -%} {%- if search_link -%} 🔍 {%- endif -%} {% endif %} {% endfor %}
{%- endmacro %} {% macro _show_raw_keyval(value) -%} {%- if value is string or value is number -%} {{ value }} {%- elif value is mapping -%} {%- for key, val in value.items() %}
{{ key }}: {{ _show_raw_keyval(val) }}
{%- endfor %} {# A string is an iterable, so we check for it above #} {%- elif value is iterable -%} {# If it's a long list, make is expandable/collapsable #} {% if value | length > 20 %}
[ [{{ value | length }} items...] {%- for item in value %}
{{ _show_raw_keyval(item) }},
{% endfor %} ]
{% else %} [ {%- for item in value %}
{{ _show_raw_keyval(item) }}
{% endfor %} ]
{% endif %} {%- else -%} {{ value | torapidjson}} {%- endif -%} {%- endmacro %} {% macro show_raw_document(doc) -%}
{{ _show_raw_keyval(doc) }}
{%- endmacro %}