Skip to content

Add human readable displayversion to dashboard metrics #5967

@sqwk

Description

@sqwk

At the moment metrics can only be formatted using Intl.NumberFormat. This falls short when displaying for example durations. Is it possible to add a human readable display (string) version that is used for non-graphs?

For example:

$this->registerMetric(new ReportMetric(
    self::METRIC_ENTRY_DURATION,
    'TIMESTAMPDIFF(MINUTE, start_time, end_time)',
    'Recorded Entry Duration',
    ReportMetric::AGGREGATE_SUM,
    null, // Intl.NumberFormat would normally go here
    function ($value) {
        $totalMinutes = $value;
        $hours = intdiv($totalMinutes, 60);
        $minutes = $totalMinutes % 60;
        return sprintf('%d:%dh', $hours, $minutes);
    }
));

(I am aware that TIMESTAMPDIFF does currently not work. See #5924 and #5966)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions