Admin App result calculation problem firebase

We have created an app in which the user has to make a prediction, or if his prediction is correct then he gets a reward for it, we have set the result in the admin app and the result calculation is also in my app. The problem is that when more users are predicting together, only 4 to 5 users’ data is being calculated, and the rest of the time the app is stopping because it is running in a loop because there is only one user. It’s a separate bucket, I’m wondering how to solve it so that all users’ results are calculated automaticaly and their rewards are added to their account .