Skip to content

Commit

Permalink
chore: address pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi committed Mar 1, 2024
1 parent c99452b commit 5d92872
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 0 additions & 4 deletions history/src/app/history/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@ type GetPriceHistoryArgs = {
currency: string
range?: string
}

type NotifyPriceChangeArgs = {
range?: PriceRange
}
4 changes: 2 additions & 2 deletions history/src/app/history/notify-price-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { checkedToCurrency } from "@domain/primitives"
import { PriceRepository } from "@services/database"
import { NotificationsService } from "@services/notifications"

export const notifyPriceChange = async ({ range }: NotifyPriceChangeArgs) => {
export const notifyPriceChange = async () => {
const quote = checkedToCurrency("USD")

if (quote instanceof Error) {
return quote
}

const rangeToQuery = range || PriceRange.OneDay
const rangeToQuery = PriceRange.OneDay
const prices = await PriceRepository().listPrices({
base: defaultBaseCurrency,
quote,
Expand Down
3 changes: 2 additions & 1 deletion history/src/config/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const databaseConfig = {
debug: process.env.DB_DEBUG === "true",
}

export const notificationsEndpoint = process.env.notificationsEndpoint || "localhost:6685"
export const notificationsEndpoint =
process.env.NOTIFICATIONS_ENDPOINT || "localhost:6685"
2 changes: 1 addition & 1 deletion history/src/services/notifications/price-changed-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const createPriceChangedEvent = ({
const usdMajorUnitToMinorUnit = (usd: number) => usd * 100

const calculatePriceChangePercentage = (initialPrice: Price, finalPrice: Price) => {
const percentage = ((finalPrice - initialPrice) / initialPrice) * 100
const percentage = Math.abs(((finalPrice - initialPrice) / initialPrice) * 100)

const direction =
finalPrice > initialPrice ? PriceChangeDirection.UP : PriceChangeDirection.DOWN
Expand Down

0 comments on commit 5d92872

Please sign in to comment.