I solved a similar but simpler problem with timetracker, a gagdet added to your Google Calendar which is exactly what I needed, it sums hours grouped by tags present in your events. I hope it helps to someone else, has been hard to find.
I'd love to hear the solution you came with btw