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

Description
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.