0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

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.
This commit is contained in:
Fabien "egg" O'Carroll 2023-09-01 11:54:43 +07:00 committed by Fabien 'egg' O'Carroll
parent a97383f2de
commit 00072a204f

View file

@ -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) {