Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REFACTOR]: Denormalize and rewrite statistics page and filters #569

Open
1 task done
winged opened this issue Jan 7, 2025 · 0 comments
Open
1 task done

[REFACTOR]: Denormalize and rewrite statistics page and filters #569

winged opened this issue Jan 7, 2025 · 0 comments
Labels
refactor This issue or pull request discusses refactoring

Comments

@winged
Copy link
Member

winged commented Jan 7, 2025

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

  • I have checked past issues to ensure that this isn't a duplicate.
@winged winged added the refactor This issue or pull request discusses refactoring label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor This issue or pull request discusses refactoring
Projects
None yet
Development

No branches or pull requests

1 participant