From 8ddc9e620e8ef22fc2be326c5ab390b2e7c0aec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Nov=C3=A1k?= Date: Fri, 18 Oct 2024 12:59:15 +0200 Subject: [PATCH] fix: when country prefix is undefined don't crash reports --- apps/offer-service/src/metrics.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/offer-service/src/metrics.ts b/apps/offer-service/src/metrics.ts index cd1a576ba..0c8a4a71d 100644 --- a/apps/offer-service/src/metrics.ts +++ b/apps/offer-service/src/metrics.ts @@ -138,7 +138,7 @@ export const reportTotalBuyOffersExpired = ({ ) const OffersStatsQueryResult = Schema.Struct({ - countryPrefix: Schema.optional(CountryPrefixE), + countryPrefix: Schema.Union(CountryPrefixE, Schema.Null), buy: Schema.Int, sell: Schema.Int, }) @@ -208,11 +208,11 @@ export const reportMetricsLayer = Layer.effectDiscard( pipe( Array.map(listOfCountries, (one) => [ reportTotalBuyOffers({ - countryPrefix: one.countryPrefix, + countryPrefix: one.countryPrefix ?? undefined, value: one.buy, }), reportTotalSellOffers({ - countryPrefix: one.countryPrefix, + countryPrefix: one.countryPrefix ?? undefined, value: one.sell, }), ]), @@ -228,11 +228,11 @@ export const reportMetricsLayer = Layer.effectDiscard( pipe( Array.map(listOfCountries, (one) => [ reportTotalBuyOffersExpired({ - countryPrefix: one.countryPrefix, + countryPrefix: one.countryPrefix ?? undefined, value: one.buy, }), reportTotalSellOffersExpired({ - countryPrefix: one.countryPrefix, + countryPrefix: one.countryPrefix ?? undefined, value: one.sell, }), ]),