kobotoolbox / kobocat

Our (backend) server for providing blank forms to Collect and Enketo and for receiving and storing submissions.
BSD 2-Clause "Simplified" License
117 stars 127 forks source link

Create null xform instances for DailyXFormSubmissionCounter #895

Closed LMNTL closed 1 year ago

LMNTL commented 1 year ago

Description

DailyXFormSubmissionCounter doesn't actually have a pre_delete signal, so the xform=NULL counter isn't getting updated when xforms are deleted. This made sense when it got deleted after 31 days, but now it's our primary way of figuring out submission data on the usage page.

This PR resolves that by making the DailyXFormSubmissionCounter function more like the MonthlyXFormSubmissionCounter:

A separate PR for kpi will handle updating the shadow model (ReadOnlyDailyXFormSubmissionCounter).

Notes

I tried to update any place where daily counters are created to include the user. Because this includes the populate_submission_counters management command, I reordered migrations so that the schema changes happen before that command is run.