Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow Availability Api #415

Closed
taylorkrause opened this issue Apr 25, 2023 · 2 comments
Closed

Slow Availability Api #415

taylorkrause opened this issue Apr 25, 2023 · 2 comments
Labels

Comments

@taylorkrause
Copy link

Describe the bug
Hello! Great library, having a lot of fun working with it so far. I have noticed some rather long wait times with the availability API. I have played around with varying the end times as to not look too far into the future for availability. This doesn't seem to have much of an affect. Are there any best practices around speeding this endpoint up?

To Reproduce

nylas = Nylas::API.new(
            app_id: ***,
            app_secret: ***
          )
          settings = nil
          scopes = nil
          if @identity.provider == "google"
            settings = {
              google_client_id: ***,
              google_client_secret: ***,
              google_refresh_token: @identity.encrypted_refresh_token
            }
            nylas_provider = "gmail"
          elsif @identity.provider == "microsoft"
            settings = {
              microsoft_client_id: ***
              microsoft_client_secret: ***,
              microsoft_refresh_token: @identity.encrypted_refresh_token
            }
            nylas_provider = "graph"
          end
          nylas_token = nylas.authenticate(
            name: @current_user.email,
            email_address: @current_user.email,
            provider: nylas_provider,
            settings: settings,
            scopes: "calendar"
          )
          api_as_user = nylas.as(nylas_token)
          found_slots = api_as_user.calendars.availability(
            duration_minutes: 30,
            interval_minutes: 30,
            start_time: Time.now.to_i,
            end_time: (Time.now + 21.days).to_i,
            emails: [@current_user.email],
            buffer: 0
          )[:time_slots]

Expected behavior
This query can sometimes take up to 30 seconds to complete with the bulk of the time surrounding the availability api.

SDK Version:
5.14

Additional context
Dialing back the end_time has no big effect on the time it takes to get a response back.

@atejada
Copy link
Contributor

atejada commented Apr 27, 2023

@taylorkrause I have tried your code, with a slight modification as I don't have active_support installed

# Import your dependencies
require 'dotenv/load'
require 'nylas'
require 'ricecream'
require 'date'

# Initialize your Nylas API client
nylas = Nylas::API.new(
    app_id: ENV["CLIENT_ID"],
    app_secret: ENV["CLIENT_SECRET"],
    access_token: ENV["ACCESS_TOKEN"]
)

found_slots = nylas.calendars.availability(
            duration_minutes: 30,
            interval_minutes: 30,
            start_time: Time.now.to_i,
            end_time: (Time.now + 21 * 24 * 60 * 60).to_i,
            emails: ["[email protected]"],
            buffer: 0
          )[:time_slots]
          
ic(found_slots)

And the response time for me is 0.37 seconds...

@mrashed-dev
Copy link
Contributor

@taylorkrause Thanks for opening this issue! Unfortunately we are unable to reproduce this issue on the SDK side. Is it possible for you to open a ticket with our support team at [email protected]? That way the support team can investigate any possible account-related issue that's causing this latency with using the Availability API. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants