Skip to content

Commit

Permalink
Don't load duplicate statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
ivank committed Jun 26, 2017
1 parent 15d74d2 commit 9d484eb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/subscriptionProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const {
differenceBy,
curry,
omit,
uniqWith,
isEqual,
} = require("lodash/fp");

function processorFieldsDiscounts(originalDiscounts, discounts) {
Expand Down Expand Up @@ -100,7 +102,10 @@ function fields(customer, originalDiscounts, subscription) {
descriptor: subscription.descriptor,
status: subscription.status,
price: subscription.price,
statusHistory: map(pick(["timestamp", "status"]), subscription.statusHistory),
statusHistory: uniqWith(
(a, b) => isEqual(a, b),
map(pick(["timestamp", "status"]), subscription.statusHistory)
),
discounts: fieldsDiscounts(originalDiscounts, subscription.discounts),
firstBillingDate: subscription.firstBillingDate,
paymentMethodId: ProcessorItem.getId(
Expand Down

0 comments on commit 9d484eb

Please sign in to comment.