From 8a9706cda9382a105728093f12a969943544e6ef Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 4 Jul 2026 11:57:52 +0200 Subject: [PATCH] Fix handling of values rounding to zero --- .../services/twitter-bot/twitter-bot.service.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/apps/api/src/services/twitter-bot/twitter-bot.service.ts b/apps/api/src/services/twitter-bot/twitter-bot.service.ts index 4e6fd5bb2c..366b016b67 100644 --- a/apps/api/src/services/twitter-bot/twitter-bot.service.ts +++ b/apps/api/src/services/twitter-bot/twitter-bot.service.ts @@ -12,6 +12,7 @@ import { import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; import { isWeekend } from 'date-fns'; +import { round } from 'lodash'; import { TwitterApi, TwitterApiReadWrite } from 'twitter-api-v2'; @Injectable() @@ -89,16 +90,16 @@ export class TwitterBotService implements OnModuleInit { }); return benchmarks - .map(({ marketCondition, name, performances }) => { - let changeFormAllTimeHigh = ( - performances.allTimeHigh.performancePercent * 100 - ).toFixed(1); + .map(({ name, performances }) => { + const performancePercent = round( + performances.allTimeHigh.performancePercent, + 3 + ); - if (Math.abs(parseFloat(changeFormAllTimeHigh)) === 0) { - changeFormAllTimeHigh = '0.0'; - } + const marketCondition = + this.benchmarkService.getMarketCondition(performancePercent); - return `${name} ${changeFormAllTimeHigh}%${ + return `${name} ${(performancePercent * 100).toFixed(1)}%${ marketCondition !== 'NEUTRAL_MARKET' ? ' ' + resolveMarketCondition(marketCondition).emoji : ''