You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The statistics / analytics pages are an unholy mess (that I've made worse a while ago trying to optimize things).
We have many filters that act on multiple values (cost center for example, but there are others).
Why refactor it
While trying to refactor and fix the statistics page (multiple futile attempts, finally resulting in the small-ish fix #568) I've come to the following conclusion:
Queries should be stupid. If a filter needs to check multiple models (cost center), the effective value should be denormalized, so the filter doesn't have to implement this-or-that logic. I'm mentioning the cost-center filter, but there are others as well.
Define Analytics requirements. The analysis page is used by many people, but some of the semantics are rather... difficult to figure out without a formal requirements definition.
How to refactor it
I think especially the analytics page might help by defining some SQL VIEWs and putting models on them. The VIEWs could already summarize the duration count, and fetch any data required for displaying a given analysis page. Then, the filtering on top of it would be absolutely trivial.
Sadly Django does not support VIEWs in a clean way, so some SQL migrations and "unmanaged" models would ensue, but I think it's still more maintainable than what we have right now. And easier to make correct, and fast, as well.
Required
I have checked past issues to ensure that this isn't a duplicate.
The text was updated successfully, but these errors were encountered:
What to refactor
The statistics / analytics pages are an unholy mess (that I've made worse a while ago trying to optimize things).
We have many filters that act on multiple values (cost center for example, but there are others).
Why refactor it
While trying to refactor and fix the statistics page (multiple futile attempts, finally resulting in the small-ish fix #568) I've come to the following conclusion:
Queries should be stupid. If a filter needs to check multiple models (cost center), the effective value should be denormalized, so the filter doesn't have to implement this-or-that logic. I'm mentioning the cost-center filter, but there are others as well.
Define Analytics requirements. The analysis page is used by many people, but some of the semantics are rather... difficult to figure out without a formal requirements definition.
How to refactor it
I think especially the analytics page might help by defining some SQL VIEWs and putting models on them. The VIEWs could already summarize the duration count, and fetch any data required for displaying a given analysis page. Then, the filtering on top of it would be absolutely trivial.
Sadly Django does not support VIEWs in a clean way, so some SQL migrations and "unmanaged" models would ensue, but I think it's still more maintainable than what we have right now. And easier to make correct, and fast, as well.
Required
The text was updated successfully, but these errors were encountered: