Alright, I have an issue and I would love some advice. Here is the
situation:
I am developing a site which syncs with Google Calendar. You can
imagine, the whole bit: list of events, create events, delete events,
all from this from our rails site.
My problem is the request times are just too slow for the initial
listing of the events. Basically, the events are being listed on a
primary profile page and I can't allow the user to have to wait that
long to see their page.
I assume the answer to this is "offload to backgroundrb" or "load the
event list using ajax" or a combination of both. I just want to hear
opinions on how others would manage this.
Short Recap: User has a profile page which lists the next 5 upcoming
events on their calendar as part of the page. I need this page to load
reasonably fast but the request to GoogleCalendar takes very long.
Could someone explain the basic process for how to do this properly in
rails. I know I need to load the Google Calendar using ajax or at least
I guessed but what would be the "best practice" method to choose...
1) create an action in rails that parses google calendar lists into an
array of events and then use an ajax request to query that action, get
the array and then display it on the javascript end
2) create a background worker that queries google calendar and then
create a rails action that starts up the background worker, gets the
events and returns them to the page invoked from an ajax request.
3) have a background worker that is continously querying google calendar
every 10 minutes for all the upcoming events for all the users and then
store them in a hash in the worker. then just query the worker and be
given the events immediately and print them to the screen
Thanks for the reply. I actually found "gcalapi" and started using it.
gcalapi didn't have support for everything I needed but I worked with it
and I have pulled off most of the google calendar actions that I needed.
I can create calendars, create, edit, and remove events. gcalapi was a
great start which got me going.
I am still having trouble with how to make Google Calendar processing
faster. Adding events, querying calendars, etc takes forever. For now, I
put off moving the actions to a background worker, but inevitably I will
have to do this eventually.
I am definitely open to sharing any tips we come across. Let me know if
there is any particular action you need help figuring out, particularly
if you work with gcalapi.
Hey I didn't see this thread again until now, but let me try to go
through here and cover a few things:
Matt mentioned a problem with dealing with non-default calendar. With
the gcalapi this is actually quite easy. I am only familiar with the
gcalapi library because it has worked out for me so far. Long story
short, there is a method called 'calendars'
You are right that you can't actually interact with GoogleCalendar. So
instead you use mocks and stubs to 'simulate' the responses Google
Calendar would give you in order to test your handling of the response.
Hope that helps
- Nathan
P.S. I am still not quite sure the proper method for offloading the
event query