mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Removed duplicate serialization for offers
- we can skip an extra `toJSON` call here by storing the value and re-using it, which means we can cut down on the number of calls, which can be particularly heavy when this codepath is hit hard
This commit is contained in:
parent
19f6f910b6
commit
44edf3d379
1 changed files with 3 additions and 1 deletions
|
@ -107,6 +107,8 @@ class OfferBookshelfRepository {
|
|||
});
|
||||
|
||||
try {
|
||||
const lastRedeemedObject = lastRedeemed.toJSON();
|
||||
|
||||
return await Offer.create({
|
||||
id: json.id,
|
||||
name: json.name,
|
||||
|
@ -126,7 +128,7 @@ class OfferBookshelfRepository {
|
|||
name: json.product.name
|
||||
},
|
||||
created_at: json.created_at,
|
||||
last_redeemed: lastRedeemed.toJSON().length > 0 ? lastRedeemed.toJSON()[0].created_at : null
|
||||
last_redeemed: lastRedeemedObject.length > 0 ? lastRedeemedObject[0].created_at : null
|
||||
}, null);
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
|
|
Loading…
Add table
Reference in a new issue