1

Have twitter bootstrap and using the progress bar.

Want to animate the bar with javascript. Figured how to animate the bar based on time, now trying to figure how to animate based on progress.

The load screen comes when pulling elements out of a mongo api. How do I go about creating this animated progress bar that will move as i pull more elements?

def self.get_xxx_users(read_db) db_users = read_db.collection("users"); db_users = db_users.find({"$and" => [:plan => { "$ne" =>"XXX"}, :'xxx.xxx_type' => {"$ne" => "XXX"}]},{}).to_a db_users 

1 Answer 1

3

Progess bars don't progress magically as such you have to provide the hooks manually.

A good but simple (and probably in need of optimisation) method of doing this is to count the number of records you wanna pick out:

db_users_count = db_users.find({"$and" => [:plan => { "$ne" =>"XXX"}, :'xxx.xxx_type' => {"$ne" => "XXX"}]},{}).count(); 

And then divide that up by a set area using limit() each time to complete a certain amount of batch processing you require.

So as you add those, say, 100 per batch (this is what I magically decided was a good number per batch of processing) users to the main array (to_a) within your ruby app you ping a response back via AJAX or something to your app telling it to increment your progess bar.

Sign up to request clarification or add additional context in comments.

2 Comments

Awesome! Thank you! now i just have to learn how to batch process and send a response back via ajax
@coldRespect I good way would be to send a JSON string and catch it via JQuery or another JS script. I admit I am not a RoR or Bootstrap user so my knowledge kinda goes as far as that :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.