Skip to content
This repository was archived by the owner on Jan 1, 2024. It is now read-only.
This repository was archived by the owner on Jan 1, 2024. It is now read-only.

Vanity metrics generating a row for each call to track #344

@ninduni

Description

@ninduni

I'm not sure if this is an issue or me misinterpreting this section of the docs:

A Vanity::Metric object responds to track! and increments a record in the database (an O(1) operation). It creates one record for each day, accumulating that day’s count. When generating reports, the values method fetches the values of all these keys (also O(1)).

In practice, calling track!(:metric) creates a new row in the vanity_metric_values table for each call, such that we're seeing thousands of rows that are of the form

id vanity_metric_id index value date
123456 1 0 1 2018-04-24
123457 1 0 1 2018-04-24

I noticed this when we started failing to load the vanity dashboard, since the query required to populate the metrics graph was timing out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions