Techioz Blog

Google API Ruby クライアントは明らかにすべてのイベントを取得しません

概要

カレンダー アプリの出発点として、Github 上の Google API Ruby クライアント サンプル リポジトリを使用しました。

したがって、私には、キャッシュが行われているように見えます。データが十分に早く返されない場合は、空の応答が返されます。再度リクエストすると一部のデータが送信され、リクエストをすればするほどより多くのデータが返されます。

おそらく私のセットアップに何か問題があり、完璧ではないと思います。

get '/' do
  #fetch all calendars
  result = api_client.execute(:api_method => calendar_api.calendar_list.list,
                              :authorization => user_credentials)
  cals = result.data.items.map do |i|
    #skip id calendar does not belong to owner or is the "private" primary one
    next if i.primary || i.accessRole != "owner"
    i.summary
  end
  cals.compact!
  #save all users mentioned in calendars in a set
  events_list = result.data.items.map do |i|
    #skip calendar if primary or not owned by user (cannot be changed anyway)
    next if i.primary || i.accessRole != "owner"
    r = api_client.execute(:api_method => calendar_api.events.list,
                           :parameters => {'calendarId' => i.id},
                           :timeMax => DateTime.now.next_month,
                           :timeMin => DateTime.now.beginning_of_month)
    #capture all calendars and their events and map it to an Array
    r.data.items.delete_if { |item| item.status == "cancelled" }
  end
  #remove skipped entries (=nil)
  events_list.compact! 
  slim :home, :locals => { :title => Konfig::TITLE, :events_list => events_list, :cals => cals}
end

解決策

この状況ではどうすればよいでしょうか。次のステップを決定する前に、次のことを実行します