Progress indicator

Sorry but there were too many typos Here is a corrected verion

I need a progress indicator that shows the progress of a parser that also writes the progress state to a db. I have several other examples of the need of informing the users of progress of processes that takes some time.

I will not put the parser in a background process, as I think there should be a more simple solution, considering all the code that needs a background process for this solution to work i my situation with many progress indicators

Could one use a remote ajax call to start the e.g the parser and then call an Ajax function at the onBefore call back, that asks the server about the progress as defined in the db

Is this a possible approach? If so what Ajax function should be used to ask the server db about progress? Are there other better solutions?

Sorry but there were too many typos Here is a corrected verion

I need a progress indicator that shows the progress of a parser that also writes the progress state to a db. I have several other examples of the need of informing the users of progress of processes that takes some time.

I will not put the parser in a background process, as I think there should be a more simple solution, considering all the code that needs a background process for this solution to work i my situation with many progress indicators

Could one use a remote ajax call to start the e.g the parser and then call an Ajax function at the onBefore call back, that asks the server about the progress as defined in the db

This should work, although you're possibly going to hit some problems with server time-out on that initial request. All browsers will give you 2 request threads at a time, some will give you more than that. So you'd be filling your pipe with the one long-running one and the second intermittent "polling" call. If your parsing operation can be broken into multiple, shorter requests, then that would be the avenue I would pursue first. Otherwise, you stand to hit some very difficult-to-diagnose problems going down this route.

As far as how to gauge progress, what sort of data are you storing, and can you do something lightweight like get a count of the number of rows when you start, estimate how many rows you will add, and then do a quick count at each status update request?

Walter

Thanks for your advices

My parsing operation is updating the db about each second I do not really understand what you mean by "your parsing operation can be broken into multiple, shorter requests", but in the current implementation is the parsing operation broken into steps and each step is performed each time the corresponding controller method is called from the periodically remote Ajax function

Yes, I can do "something lightweight like get a count etc" I am doing it now and storing the result in the database

Although this approach works for the parsing I do not think it is the way to go for all processes that needs a progress indicator. It seems to complicated for just beeing able to inform the user about progress. I am looking for a simplier method How is this problem solved bythe rails community? What is best practice ?

Thanks for your advices

My parsing operation is updating the db about each second I do not really understand what you mean by "your parsing operation can be broken into multiple, shorter requests", but in the current implementation is the parsing operation broken into steps and each step is performed each time the corresponding controller method is called from the periodically remote Ajax function

My mistake. I was thinking that your parsing operation was something larger, like maybe breaking down a large input into multiple records within the span of one request.

Walter