From 00072a204f98da50a4a3524f387bdef0d83d3b22 Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Fri, 1 Sep 2023 11:54:43 +0700 Subject: [PATCH] Simplified use of ValueObject in OfferRepository I don't think we need to instantiate and use the `equals` method here. It adds an extra dependency to the Repository implementation, but it is slightly more "correct" as it means that we leak internals by comparing strings exactly? The ValueObject pattern here was very much a trial and isn't something we're necessarily sticking with, so I don't see a problem with this string comparison. --- ghost/offers/lib/application/OfferRepository.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ghost/offers/lib/application/OfferRepository.js b/ghost/offers/lib/application/OfferRepository.js index 1a79985323..69ed24e7db 100644 --- a/ghost/offers/lib/application/OfferRepository.js +++ b/ghost/offers/lib/application/OfferRepository.js @@ -2,7 +2,6 @@ const {flowRight} = require('lodash'); const {mapKeyValues, mapQuery} = require('@tryghost/mongo-utils'); const DomainEvents = require('@tryghost/domain-events'); const Offer = require('../domain/models/Offer'); -const OfferStatus = require('../domain/models/OfferStatus'); const statusTransformer = mapKeyValues({ key: { @@ -197,7 +196,7 @@ class OfferRepository { duration: offer.duration.value.type, duration_in_months: offer.duration.value.type === 'repeating' ? offer.duration.value.months : null, currency: offer.currency ? offer.currency.value : null, - active: offer.status.equals(OfferStatus.create('active')) + active: offer.status.value === 'active' }; if (offer.isNew) {