S
S
Svyatoslav Torg2017-02-14 17:38:39
Yii
Svyatoslav Torg, 2017-02-14 17:38:39

How to display the "status" of an action being processed?

Hello,
there is an action that checks whether there are files for records in the database - it works.
But I would like to see at what stage the processing is at the time of execution.
I know about the progress widget, but how can I transfer data to it? After all, the action has not yet fully worked out, and has not rendered the view)
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-02-15
@sefkiss

But I would like to see at the time of execution at what stage the processing is

There is no way you can do this at the time of the action execution: when you access the action, the browser generates and sends the appropriate request, when the action completes it returns a response to the browser. There is no intermediate data between these two events. Therefore, making progress display is not 5 minutes of work. If you still want to do this, then you can implement the functionality something like this:
1. At the time of accessing the action, it simply launches a third-party processing process (for example, using the same queue server) and returns a response to the browser.
2. After that, the client side is monitored. For this task, for example, you can use WebSocket to connect the client to the server (you can, of course, poll the state of the process with Ajax, but this is a crutch)
3. After receiving information about the download process, it is displayed to the user at the javascript level

E
entermix, 2017-02-14
@entermix

You can write intermediate results to the database, for example, and from there read and give to the client.
Ate to do according to feng shui - use background tasks / queues, but the principle is the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question