{# 사이트 트래픽 화면 공통 조각 #} {% macro num(value) -%}{{ '{:,}'.format(value or 0) }}{%- endmacro %} {% macro when(value) -%}{{ value.strftime('%m-%d %H:%M') if value else '-' }}{%- endmacro %} {% macro stat_card(label, value, cls='') %}
{{ label }}
{{ value }}
{% endmacro %} {# 차트 + "표로 보기"(색 대비가 낮은 계열이 있어 표를 항상 함께 둔다) #} {% macro chart_card(title, chart_id, daily, columns, col='col-12') %}

{{ title }}

표로 보기
{% for key, label in columns %}{% endfor %} {% for d in daily | reverse %} {% for key, label in columns %}{% endfor %} {% endfor %}
날짜{{ label }}
{{ d.date.strftime('%Y-%m-%d') }}{{ num(d[key]) }}
{% endmacro %} {# rows: dict 목록, columns: [(키, 제목, 숫자여부)] #} {% macro table_card(title, rows, columns, col='col-12 col-lg-6', empty='기록 없음') %}

{{ title }}

{% for key, label, numeric in columns %}{% endfor %} {% for row in rows %} {% for key, label, numeric in columns %} {% if numeric %} {% elif key in ('last_seen', 'at') %} {% else %} {% endif %} {% endfor %} {% else %} {% endfor %}
{{ label }}
{{ num(row[key]) }}{{ when(row[key]) }}{{ row[key] if row[key] is not none else '-' }}
{{ empty }}
{% endmacro %} {% macro content_path(content_type, content_id) -%} {%- if content_type == 'video' -%}/video/{{ content_id }} {%- elif content_type == 'ssul' -%}/ssul/{{ content_id }} {%- elif content_type == 'p2v_f1' -%}/p2v/f1/{{ content_id }} {%- elif content_type == 'p2v_playreel' -%}/p2v/playreel/{{ content_id }} {%- else -%}{{ content_type }}/{{ content_id }}{%- endif -%} {%- endmacro %}