SuperHyperInstantFutureTime / TrackShift

0 stars 0 forks source link

Uploads: cache earnings for uploads and products #142

Closed g105b closed 9 months ago

g105b commented 11 months ago

Currently the earnings are calculated every page render, but when there are hundreds of thousands of usages, render times start getting quite slow.

The total earnings can easily be cached on the upload. Products probably need to have some sort of invalidation technique so they can update when there's more usages imported.

g105b commented 11 months ago

As said above, upload earnings will cache perfectly easily: a new field on the Upload table to record the earning once.

Products will need invalidating. This can be done by introducing a single new field on the Product table for cached earnings. When a new usage is processed that touches this product, we can set this cache to null, forcing it to be recalculated again.

richardbirkin commented 10 months ago

Discussion:

An upload's total earnings can be cached, and that will never change (the way things are currently set up)

A product's total earnings can be cached. If a new upload contains 1 or more rows relating to that product, the cache is cleared and recached.

No need to cache the costs and splits as these will be few in number.

The outgoing and profit are just simple calculations.

richardbirkin commented 10 months ago

Bug reported #152

richardbirkin commented 10 months ago

Bug reported #154