Calculating Progress Bar Dynamically

Context
I have a reading app with multiple books and chapters. At the bottom of each chapter is a button called “Marked as Read”, which triggers workflow to write the chapter and username to the database . I can then use that info to track how many times someone reads a chapter using count. I have a progress bar at the top of each book that I would like to move based on the amount of chapters read for a given book. The challenge in moving that progress bar is that a single chapter might be marked as read many times so i can’t simply move the progress based on a certain increment every time it’s clicked.

I found a solution but it has very poor performance. I am using the Toolbox plugin where i write the following expression:

Search for Matthew’s Counters:last item is not empty:formatted as number. I used the “is not empty” to make it a boolean and convert it to a number so it gives me 0 or 1.

The Search has 2 constraints, 1 for Chapter and one for the user (so it only counts current user).
I multiple this expression for every chapter and then divide by number of chapters * 100 which i use for my progress bar count. That works but if I multiple that expression 28 times, bubble has to calculate each one and it takes about 3-5 seconds every time. And some books have upwards of a 100 chapters. Is there a better solution that would improve performance?

Thanks!
Rob

Put in your progress bar percentage field.

(do search for Current user’s Counters)(book = current page’s book’s)Chapter:last item / current page’s book’s chapters *100

That if you save the book in your Counter DB

I didn’t think I could put that long expression into the progress bar plugin but looks like i can. Not sure how much it will speed things up but I can give it a try.