Skip to content

Commit

Permalink
no neg forecasts
Browse files Browse the repository at this point in the history
  • Loading branch information
waynebruce0x committed Jan 27, 2025
1 parent bc115a0 commit 14307e8
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions utils/convertToChartData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,24 @@ function findPreviouslyEmitted(
} {
let gradientLength: number = GRADIENT_LENGTH;

const recentlyEmitted = relatedSections
.map((d: ChartSection) => {
const unlocked: number[] = d.data.unlocked;
const length: number = unlocked.length;

if (GRADIENT_LENGTH > length) {
gradientLength = length;
return unlocked[length - 1];
}

return (
unlocked[length - 1] - unlocked[Math.floor(length - GRADIENT_LENGTH)]
);
})
.reduce((p: number, c: number) => p + c, reference);
const recentlyEmitted = Math.max(
0,
relatedSections
.map((d: ChartSection) => {
const unlocked: number[] = d.data.unlocked;
const length: number = unlocked.length;

if (GRADIENT_LENGTH > length) {
gradientLength = length;
return unlocked[length - 1];
}

return (
unlocked[length - 1] - unlocked[Math.floor(length - GRADIENT_LENGTH)]
);
})
.reduce((p: number, c: number) => p + c, reference),
);

const totalEmitted: number | undefined = relatedSections
.map((d: ChartSection) => d.data.unlocked[d.data.unlocked.length - 1])
Expand Down

0 comments on commit 14307e8

Please sign in to comment.