Managing Google Calendar Integration

Alright, I have an issue and I would love some advice. Here is the
situation:

I am developing a site which syncs with Google C… 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 C. 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

  4. something inevitably smarter?

Please help. sorry this is long.

Hi Nathan

I’m in the process of scoping out a project which sounds identical to
yours.

So far I’ve found two libraries out there, I think there may be more

sudo gem install googlecalendar

http://googlecalendar.rubyforge.org/plugins/doc/

I’ve built a simple app with googlecalendar and I’m in touch with
Benjamin, he’s being very patient with me :slight_smile: Still got some problems
using it.

sudo gem install gcalapi
http://rubyforge.org/projects/gcalapi/

Just found this one, I’ll be looking at it today.

Maybe we could share how we’re getting on?

It’s a shame there isn’t an official google one, I understand there may
be some pressure on Google to do sort it out.

Matt

Hi Nathan

Great to hear from someone else going through this process. I’ve gone
down the googlecalendar route for now.

I’m certain we’ll be able to share, I too will have to think long and
hard about processing speeds in the very near future, got to make all
the things I need to work work first though. :slight_smile:

One problem I’ve got right now is posting events to Calendars that are
not your default calendar.

Have you got that working? I can’t work out what format of the URI to
use, it’s proving to be a pain in the ass. I think it’s becuase some
people call it something, and some other people call it another.

If you have got it working, I’d love to see an example of the URI format
you used?

Speak soon

matt

Hey Matt,

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 C. 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 was wondering how you test the google calendar implementation.
It seems that you cannot send actually data to google on your local
server, so I am wondering if there is a way around this. Or do I need
to launch the site on an actual server? thanks.

On Mar 31, 9:24 pm, Nathan E. <rails-mailing-l…@andreas-

Hey, sorry to bother you like this but I am starting a ruby rails
calendar project and considering using gcalapi. I was just wondering
how it ended up working out and how your overall experience with it
was. It doesnt look like theres any tutorials or blogs on how to use
it so I am a little intimidated. Thanks, Dave

On Apr 21, 3:46 am, Nathan E. <rails-mailing-l…@andreas-

Hey I was wondering how you test the google calendar implementation.
It seems that you cannot send actually data to google on your local
server, so I am wondering if there is a way around this. Or do I need
to launch the site on an actual server? thanks.

On Apr 21, 3:46 am, Nathan E. <rails-mailing-l…@andreas-

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’

http://gcalapi.rubyforge.org/classes/GoogleCalendar/Calendar.html#M000012

This method returns a list of all the calendars for a given google
account. Then I can create a new calendar like so:

GoogleCalendar::Calendar.new(@srv, feed)

and then query for events or create new events from there. It abstracts
the need to mess with the URL manually.

I have not tried any alternatives but I was pretty satisfied with
gcalapi. There are not too many tutorials. I learned how to use it
through the rdocs

http://gcalapi.rubyforge.org/

and also just by straight up looking at the source code.

Overall tho, using it was pretty self explanatory.

As far as testing the google calendar implementation, this is where
mocks/stubs come in handy. Check out the library ‘mocha’

http://mocha.rubyforge.org/

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