Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Enable searching customers by their IDs and optimize # of database queries #236

Merged
merged 1 commit into from
Oct 12, 2020
Merged

Enable searching customers by their IDs and optimize # of database queries #236

merged 1 commit into from
Oct 12, 2020

Conversation

vxio
Copy link
Member

@vxio vxio commented Oct 8, 2020

This PR makes two main changes:

  1. Adds the ability to search by customerIDs: GET /customers?customerIDs=id_1,id_2

  2. Reduces the number of database queries triggered by GET /customers
    A call to GET /customers that matches n=25 customers would trigger ~100 or n*4 database queries:
    searchCustomers would call getCustomer() n times

    • each call to getCustomer() would also trigger 3 additional db queries to fetch the customer's addresses, phones, and metadata.
      Thus, n * ( getCustomer() + getAddresses() + getPhones() + getMetadata() ) -> 25 * (1+1+1+1) = 100

Fixes #220 #216

@adamdecaf adamdecaf self-requested a review October 9, 2020 00:36
pkg/client/api/openapi.yaml Show resolved Hide resolved
pkg/customers/customer_search.go Show resolved Hide resolved
pkg/customers/customer_search.go Outdated Show resolved Hide resolved
pkg/customers/customer_search.go Show resolved Hide resolved
pkg/customers/customers.go Outdated Show resolved Hide resolved
pkg/customers/customer_search_test.go Outdated Show resolved Hide resolved
fix: bug in updating a customer's phones and addresses
@vxio vxio merged commit b4bce90 into moov-io:master Oct 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

customers: add filter for customerIDs in searchCustomers repository method
4 participants