netzkolchose / django-computedfields

Provides autogenerated autoupdated database fields for model methods.
MIT License
94 stars 14 forks source link

good story to deal with custom managers #122

Open jerch opened 1 year ago

jerch commented 1 year ago

Coming from #120 - we prolly want some sort of a setting/argument around computed fields to specify a certain manager to be used. This needs some thinking how to shape / where to place such a setting, as we currently only have an explicit API on field level, while managers act model-wide.

jerch commented 1 year ago

Some thoughts around custom cf managers...

Early ideas how to shape this:

What should be covered by this:

Hmm not sure yet, if it is worth to be implemented:

On the other hand, it would partially solve a current issue with cfs - a cf, that aggregates many datapoints into a final result gets always immediately updated from a single datapoint change. If there are multiple changes at different datapoints at once, this create a lot of nonsense interim updates, which cannot be avoided currently with the instance obj interface. While custom managers can partially solve this, it still might not be the best way to solve it.

Overall it boils down to the question, if we want to allow some sort of explicit interim desync state to stack up multiple updates into one final one.*

Still very unsure about this...


[*] So far this did not came up as a real issue. But a prolly better way to solve that might be some sort of a context, which allows to update db fields without triggering any cf updates immediately, instead doing it at the end in one mass action...