leostratus / lunchbattle

White Day Hackathon Project Repo
1 stars 1 forks source link

Change UJS behaviour on search#create #13

Open chancancode opened 12 years ago

chancancode commented 12 years ago

Right now, results are returned from DB immediately if that same search (same query+category) was ran less than a day ago. In this case nothing needs to be changed. However, in the case where we have no (fresh) cached result for the search, right now we hit the API directly while keeping the user waiting. This is problematic in two ways: 1. bad UX (could fix that by adding a spinning gear icon, which we need to do anyways) 2. because our (free) heroku instance can only service ONE request at a time, and cannot process other requests while processing the current one. A typical yelp API call takes anywhere from a few seconds to upwards of 10seconds in our testing yesterday. This means if a user is executing a search, no one else could access our site, even just loading the homepage. I will be moving the search logic to a background worker thread, but that means the front end will need to poll the server for the result. I'll update you when I'm done working with the async stuff, but I'm opening this now to keep track of progress.