django / djangoproject.com

Source code to djangoproject.com
https://www.djangoproject.com/
BSD 3-Clause "New" or "Revised" License
1.88k stars 948 forks source link

Dashboard: New ticket today/this week no longer calculated #1690

Open sarahboyce opened 5 days ago

sarahboyce commented 5 days ago

If you go to the dashboard: https://dashboard.djangoproject.com/

You will see that "New tickets today" and "New tickets this week" have been broken since roughly May 2024

For example: image

The filters on Trac still work

It would be great to fix these and back-calculate the missed ones

bmispelon commented 5 days ago

Oh interesting, maybe no one has filed a new ticket since May? 🙊 (looking into it now)

bmispelon commented 5 days ago

I believe I broke it with 65320ed61a7adf4d594c651e823fa4e8a43571bb. The two metrics that use time= [1] [2] haven't been working right since May which is probably when that change was deployed. But they're failing silently (by just inserting 0) which is why we haven't been notified of the breakage.

The root of the issue is that queyring the time field doesn't actually work, but that should be fixable. I'll also see how complicated it will be to add a data migration to go and fix the historical data, but I'm cautiously optimistic.

Thanks for reporting this issue! ✨

[1] https://dashboard.djangoproject.com/metric/new-tickets-today/ [2] https://dashboard.djangoproject.com/metric/new-tickets-week/

bmispelon commented 3 days ago

My PR with a fix is ready. It includes a new management command to fix the data.

Testing things locally is a bit involved, here's how you can do it:

Prerequisites:

Steps:

1) decompress the gzipped csv files (in a bash shell)

gunzip dashboard_trac_metric_2024.csv.gz trac_tickets.csv.gz

2) Figure out the id of the TracTicketMetric content type (in a psql shell for the db djangoproject)

SELECT id FROM django_content_type WHERE app_label='dashboard' AND model='tracticketmetric';

3) Modify the dashboard CSV file to use the right content type id (bash shell)

# replace XX with the id you got in the previous step
sed -iE 's/^64/XX/' dashboard_trac_metric_2024.csv

4) Load the (broken) dashboard data (psql shell for djangoproject)

\copy dashboard_datum (content_type_id, object_id, timestamp, measurement) FROM 'dashboard_trac_metric_2024.csv' WITH CSV

5) Load the barebones Trac ticket data (enough to be able to run the fix command) (psql shell for code.djangoproject)

\copy ticket (time, changetime) FROM 'trac_tickets.csv' WITH CSV

6) Visit http://dashboard.djangoproject.localhost:8000 (make sure runserver is running) and see that the first two metrics show 0

7) Run the fix command:

python manage.py fix_trac_metrics --yes new-tickets-today new-tickets-week

8) Load the dashboard again, check that the two metrics are fixed


dashboard_trac_metric_2024.csv.gz trac_tickets.csv.gz