I’ve been working on a problem for some time now and it’s been giving me some problems. It revolves around best practise when it comes to saving complex data sets in Bubble, and trying to reduce workload as much as possible. It’s a bit of a time consuming one to explain, so forgive the long message -
First, to describe my app and data structures a little bit.
Users complete ‘Tests’ in the app, which generates various summary metrics in return. I’ll call these summary metrics A, B and C, as well as a ‘Topic’, which is a category for the test. There are maybe 15 topics in total.
So a given ‘Test’ in the database would possess:
Date User Topic Metric A Metric B Metric C
A ‘Performance Summary (PS)’ in the database summarises the scores for a collection of these ‘Tests’ for a given ‘Topic’. So a user would have a series of these PS’s, always one per ‘Topic’, and each would have a series of summary metrics based on the underlying ‘Tests’. I’ll call these summary metrics X, Y and Z.
So a given ‘PS’ in the database would possess:
User Topic Metric X Metric Y Metric Z
Each time a user completes a ‘Test’ for a given ‘Topic’, the app needs to generate a new PS for this ‘Topic’. That process involves taking all the ‘Tests’ completed in the preceding 8 weeks (now including the newly completed test), and re-calculate metrics X, Y and Z for the ‘Topic’, before overwriting the old entry.
The challenge is that a user might submit 6 tests in a single sitting (each a different topic), and upon submitting their results, the app needs to generate the summary metrics for each of the 6 new tests (metrics A, B and C), before then recalculating the PS’s for the 6 topics (X, Y, Z).
Of course the data objects are also significantly more complicated that indicated here, each possessing multiple summary metrics - not just the 3.
What I need is a very efficient way to process all this data and save it all back to Bubble. It doesn’t need to be instant, so backend options are on the table.
I do have a working solution, but trying to prevent issues at scale. Any thoughts, feedback greatly appreciated!