Skip to content

More efficient way to retrieve service schedule plan times #1429

@aberamseyer

Description

@aberamseyer

Related Product
Which product is this feature related to?
Services

Is your feature request related to a problem? Please describe.
Finally getting around to creating this issue as directed a few months ago here.

Primary problem: retrieving every date of service for every person in any service schedule requires thousands of API requests.

We want understand "who is regularly serving". We have a sync process that runs for many data points, and the service schedule portion is by far the slowest. Today, this requires an API request per person, which can easily be in the thousands and make our sync take hours.

Today, our approach is:

  1. Page through services/v2/teams?include=people in its entirety, every time, and collect all the person_ids from it.
  2. Page through services/v2/people/<person_id>/schedules?include=plan_times&filter=after&after=<last_sync_time> for every person_id from the v2/teams response

Describe the solution you'd like
We would love to have an endpoint to retrieve all the service schedules for all people, particularly ordered by last update date (descending) so we can page through the API until we reach the date since our last synchronization. Maybe services/v2/schedules?include=plan_times? We're open to suggestions.

Our current implementation uses the following data points from services/v2/people/<person_id>/schedules

  1. schedule.attributes.service_type_name
  2. schedule.attributes.status
  3. schedule.relationships.team.data.id
  4. schedule.relationships.plan_times[*].attributes.starts_at

All from https://developer.planning.center/docs/#/apps/services/2018-11-01/vertices/schedule

Additional context

We also want to track team assignments, so we'll continue to use services/v2/teams?include=people for that regardless.

We always track the last time our api batches run, so ordering by an updated_at, descending is sufficient for us to know what has changed. We stop paging through the API when we reach updated_at values before the time of our last sync.

We're not currently in a position to set up a webhooks consumer for services changes, but that may work in the future. However, I don't think the currently available subscriptions include the data we're looking for.

Overall, we're just looking to reduce our API footprint to make things faster because we know we're causing a lot of load.

I have..

  • Reviewed the documentation found at https://developer.planning.center/docs
  • Searched for previous issues asking for this feature request
  • Removed all private information from this issue (credentials, tokens, emails, phone numbers, etc.)
  • Reviewed my issue for completeness

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions