Google API ruby客户端显然不能获取所有事件
我使用Github上的GoogleAPI Ruby客户端作为日历应用程序的起点 它运行良好,通常没有问题。然而,最近我注意到我的应用程序在生产中并没有获取所有事件。在通过ruby客户端请求了一些日历之后,我在一个表中呈现事件。在我的第一次通话中,只有我用我的应用程序生成的日期,根本没有从日历中获取任何数据。在第二次请求时,一些日历将返回数据,并重新加载应用程序几次,所有日历将返回事件 所以在我看来,似乎有一些缓存正在进行。如果数据返回速度不够快,将向我发送一个空响应。再次请求发送一些数据,请求越多,返回的数据越多 可能是我的设置有问题,我认为不完美:Google API ruby客户端显然不能获取所有事件,ruby,google-api-ruby-client,Ruby,Google Api Ruby Client,我使用Github上的GoogleAPI Ruby客户端作为日历应用程序的起点 它运行良好,通常没有问题。然而,最近我注意到我的应用程序在生产中并没有获取所有事件。在通过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
顺便说一句:timeMax和:timeMin也没有按预期工作,但我想这是一个不同的问题。代码似乎不是这里的问题 我猜下面的一种情况正在发生
谢谢。我真的无法复制我自己的错误,但你的答案对我来说很有意义,所以我想我会给你50分:)