{% extends 'base.html' %} {% load static %} {% block title %}{{ metric.name }} - Metric Definition{% endblock %} {% block content %}
Metric Overview

{{ metric.name }}

{{ metric.description|default:"No description provided" }}

{{ metric.get_category_display }}
{{ metric.get_metric_type_display }}
{{ metric.unit|default:"N/A" }}
{{ metric.format|default:"Default" }}
{% if metric.data_source %} {{ metric.data_source.name }} {% else %} Not specified {% endif %}
{{ metric.get_calculation_frequency_display|default:"Manual" }}
{% if metric.status == 'active' %} {% elif metric.status == 'inactive' %} {% else %} {% endif %}
{% if metric.status == 'active' %} Active {% elif metric.status == 'inactive' %} Inactive {% else %} Draft {% endif %}
{{ metric.calculation_count|default:"0" }} Calculations
{{ metric.widget_count|default:"0" }} Widgets
Formula & Configuration
Calculation Formula:
{% if metric.formula %}
{{ metric.formula }}
{% else %}
No formula defined for this metric.
{% endif %}
{% if metric.sql_query %}
SQL Query:
{{ metric.sql_query }}
{% endif %} {% if metric.parameters %}
Parameters:
{% for param in metric.parameters %} {% endfor %}
Parameter Type Default Value Description
{{ param.name }} {{ param.type }} {{ param.default_value|default:"N/A" }} {{ param.description|default:"No description" }}
{% endif %}
Current Value & Trends
Current Value

{{ metric.current_value|default:"N/A" }}

{% if metric.unit %} {{ metric.unit }} {% endif %}
{% if metric.change_percentage %} {{ metric.change_percentage|floatformat:1 }}% vs last period {% endif %}
{% if metric.last_calculated %}
Last calculated: {{ metric.last_calculated|timesince }} ago
Calculation time: {{ metric.calculation_duration|default:"N/A" }}
{% endif %}
Calculation History
{% if metric.calculation_history %}
{% for calculation in metric.calculation_history %} {% endfor %}
Date Value Status Duration Triggered By Actions
{{ calculation.calculated_at|date:"M d, Y H:i" }} {{ calculation.value }} {% if metric.unit %} {{ metric.unit }}{% endif %} {% if calculation.status == 'success' %} Success {% elif calculation.status == 'error' %} Error {% else %} Pending {% endif %} {{ calculation.duration|default:"N/A" }} {{ calculation.triggered_by|default:"System" }}
{% else %}
No Calculation History

Calculation history will appear here after the first calculation.

{% endif %}
Quick Actions
Edit Metric
{% if metric.status == 'active' %} {% else %} {% endif %} Delete
Metric Information
{{ metric.created_by|default:"System" }}
{{ metric.created_at|date:"M d, Y H:i" }}
{{ metric.updated_at|date:"M d, Y H:i" }}
{{ metric.version|default:"1.0" }}
{% if metric.tags %}
{% for tag in metric.tags %} {{ tag }} {% endfor %}
{% endif %}
Related Widgets
{% if metric.related_widgets %}
{% for widget in metric.related_widgets %}
{{ widget.name }}

{{ widget.dashboard.name }}

{% endfor %}
{% else %}

No widgets using this metric

{% endif %}
Performance
{{ metric.avg_calculation_time|default:"N/A" }}
Avg Calculation Time
{{ metric.success_rate|default:"N/A" }}%
Success Rate
{{ metric.data_freshness|default:"N/A" }}
Data Freshness
{% endblock %}