Process Progress from Frontend


Hi all,

Let’s just say I have a function on a controller with some queries to database filtering and ordering results. I’ve already checked that 15000ms is enough for Adonis to abort that query. I solved that using paginate, creating indexes etc etc…

Now I have a bigger problem, I have to generate a Cycle, it looks like:

Select all HOSTS from a table that have one or many TEMPLATES assigned
-----For each TEMPLATE assigned
-----------For each ITEM in this TEMPLATE which has been marked as “useful” generate a new object on a new table.
-----------End For
-----End For
End For

This process has to build 300000 aprox. new models, and insertions on database (HOSTS with TEMPLATES ASSIGNED(1200)AVERAGE OF ASSIGNED TEMPLATES BY HOST (1) AVERAGE OF ITEMS PER TEMPLATE(250)).

I’m new to javascript/typescript, I’m new to AdonisJS, I’m new to Angular, but my app it’s working, I can CRUD every object on frontend and Controllers on backend work ok, resourceful routes with authentication. I’m a sysadmin with no holidays :slight_smile:

I decided not to put this heavy process on frontend because a closed window could just stop the execution so I think that it’s place would be Adonis Backend.

Is there any way to call the api, launch this process and see the progress from frontend? Where would it fits better, hook? controller? ace command? migration file? How could I check for progress from frontend?

Thank you and sorry for my poor english.



I’ve just saw this code using stream:

Now, how do I measure the progress of the process from frontend?


I would probably look at something like mqtt… As progress is made your backend job can push messages to an mqtt topic that your ui is subscribed to, as those messages come in update the ui… If you’re able to calculate the total number that will run, you can include percentage and eta data pretty easily.

Mqtt is a fantastic protocol. AWS has an mqtt broker you can use, as part of their IoT suite.