From be0c8a7cf5b1844aac9a1e1c96f3e53aa798c4fa Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Fri, 12 Apr 2019 15:47:57 +0300 Subject: [PATCH] InboxPage: use sparse fields to improve query performance --- src/containers/InboxPage/InboxPage.duck.js | 8 ++++++++ src/util/types.js | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/containers/InboxPage/InboxPage.duck.js b/src/containers/InboxPage/InboxPage.duck.js index 3e94cedc..7f485066 100644 --- a/src/containers/InboxPage/InboxPage.duck.js +++ b/src/containers/InboxPage/InboxPage.duck.js @@ -94,6 +94,14 @@ export const loadData = (params, search) => (dispatch, getState, sdk) => { only: onlyFilter, lastTransitions: TRANSITIONS, include: ['provider', 'provider.profileImage', 'customer', 'customer.profileImage', 'booking'], + 'fields.transaction': [ + 'lastTransition', + 'lastTransitionedAt', + 'transitions', + 'payinTotal', + 'payoutTotal', + ], + 'fields.user': ['profile.displayName', 'profile.abbreviatedName'], 'fields.image': ['variants.square-small', 'variants.square-small2x'], page, per_page: INBOX_PAGE_SIZE, diff --git a/src/util/types.js b/src/util/types.js index 8fc152ad..c008cccd 100644 --- a/src/util/types.js +++ b/src/util/types.js @@ -339,7 +339,7 @@ propTypes.transaction = shape({ id: propTypes.uuid.isRequired, type: propTypes.value('transaction').isRequired, attributes: shape({ - createdAt: instanceOf(Date).isRequired, + createdAt: instanceOf(Date), lastTransitionedAt: instanceOf(Date).isRequired, lastTransition: oneOf(TRANSITIONS).isRequired, @@ -357,7 +357,7 @@ propTypes.transaction = shape({ lineTotal: propTypes.money.isRequired, reversal: bool.isRequired, }) - ).isRequired, + ), transitions: arrayOf(propTypes.transition).isRequired, }), booking: propTypes.booking,