Skip to content

Commit

Permalink
fix: early return if missing price data
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi committed Feb 28, 2024
1 parent ed0a866 commit e08c196
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions history/src/app/history/notify-price-change.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defaultBaseCurrency } from "@config"
import { PriceRange } from "@domain/price"
import { PriceRange, PriceRepositoryError } from "@domain/price"
import { checkedToCurrency } from "@domain/primitives"
import { PriceRepository } from "@services/database"
import { NotificationsService } from "@services/notifications"
Expand All @@ -18,10 +18,14 @@ export const notifyPriceChange = async ({ range }: NotifyPriceChangeArgs) => {
range: rangeToQuery,
})

if (prices instanceof Error) {
if (prices instanceof PriceRepositoryError) {
return prices
}

if (prices.length < 2) {
return
}

const notificationsService = NotificationsService()

return notificationsService.priceChanged({
Expand Down

0 comments on commit e08c196

Please sign in to comment.