feat(analysis): bold month names for DB-sourced data, regular for external
This commit is contained in:
@@ -6,6 +6,7 @@ type MonthlyLastRow = {
|
|||||||
month: string;
|
month: string;
|
||||||
type: string;
|
type: string;
|
||||||
buy: number;
|
buy: number;
|
||||||
|
source: "db" | "external";
|
||||||
};
|
};
|
||||||
|
|
||||||
type ExternalQuote = {
|
type ExternalQuote = {
|
||||||
@@ -94,7 +95,7 @@ export async function getMonthlyLast(c: Context) {
|
|||||||
for (const type of TYPES) {
|
for (const type of TYPES) {
|
||||||
const buy = dbMap.get(month)?.get(type);
|
const buy = dbMap.get(month)?.get(type);
|
||||||
if (buy !== undefined) {
|
if (buy !== undefined) {
|
||||||
result.push({ month, type, buy });
|
result.push({ month, type, buy, source: "db" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,13 +153,13 @@ export async function getMonthlyLast(c: Context) {
|
|||||||
for (const type of TYPES) {
|
for (const type of TYPES) {
|
||||||
const dbBuy = dbMap.get(month)?.get(type);
|
const dbBuy = dbMap.get(month)?.get(type);
|
||||||
if (dbBuy !== undefined) {
|
if (dbBuy !== undefined) {
|
||||||
result.push({ month, type, buy: dbBuy });
|
result.push({ month, type, buy: dbBuy, source: "db" });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const extBuy = externalData.get(type)?.get(month);
|
const extBuy = externalData.get(type)?.get(month);
|
||||||
if (extBuy !== undefined) {
|
if (extBuy !== undefined) {
|
||||||
result.push({ month, type, buy: extBuy });
|
result.push({ month, type, buy: extBuy, source: "external" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type CurrencyValues = {
|
|||||||
type MonthRow = {
|
type MonthRow = {
|
||||||
month: MonthKey;
|
month: MonthKey;
|
||||||
label: string;
|
label: string;
|
||||||
|
fromDb: boolean;
|
||||||
BELO: CurrencyValues;
|
BELO: CurrencyValues;
|
||||||
BLUE: CurrencyValues;
|
BLUE: CurrencyValues;
|
||||||
BNA: CurrencyValues;
|
BNA: CurrencyValues;
|
||||||
@@ -117,7 +118,12 @@ export function MonthlyVariationTable() {
|
|||||||
|
|
||||||
const monthsMap = new Map<
|
const monthsMap = new Map<
|
||||||
MonthKey,
|
MonthKey,
|
||||||
{ BELO: number | null; BLUE: number | null; BNA: number | null }
|
{
|
||||||
|
BELO: number | null;
|
||||||
|
BLUE: number | null;
|
||||||
|
BNA: number | null;
|
||||||
|
dbTypes: Set<string>;
|
||||||
|
}
|
||||||
>();
|
>();
|
||||||
|
|
||||||
for (const entry of monthlyData) {
|
for (const entry of monthlyData) {
|
||||||
@@ -125,10 +131,12 @@ export function MonthlyVariationTable() {
|
|||||||
BELO: null,
|
BELO: null,
|
||||||
BLUE: null,
|
BLUE: null,
|
||||||
BNA: null,
|
BNA: null,
|
||||||
|
dbTypes: new Set(),
|
||||||
};
|
};
|
||||||
if (entry.type === "BELO") existing.BELO = entry.buy;
|
if (entry.type === "BELO") existing.BELO = entry.buy;
|
||||||
if (entry.type === "BLUE") existing.BLUE = entry.buy;
|
if (entry.type === "BLUE") existing.BLUE = entry.buy;
|
||||||
if (entry.type === "BNA") existing.BNA = entry.buy;
|
if (entry.type === "BNA") existing.BNA = entry.buy;
|
||||||
|
if (entry.source === "db") existing.dbTypes.add(entry.type);
|
||||||
monthsMap.set(entry.month, existing);
|
monthsMap.set(entry.month, existing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +183,7 @@ export function MonthlyVariationTable() {
|
|||||||
return {
|
return {
|
||||||
month,
|
month,
|
||||||
label: formatMonth(month),
|
label: formatMonth(month),
|
||||||
|
fromDb: (current?.dbTypes.size ?? 0) > 0,
|
||||||
BELO: {
|
BELO: {
|
||||||
variation: beloVar,
|
variation: beloVar,
|
||||||
prev: prevData?.BELO ?? null,
|
prev: prevData?.BELO ?? null,
|
||||||
@@ -223,7 +232,9 @@ export function MonthlyVariationTable() {
|
|||||||
className="rounded-lg border bg-card p-3 text-sm"
|
className="rounded-lg border bg-card p-3 text-sm"
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-between mb-2">
|
<div className="flex items-center justify-between mb-2">
|
||||||
<span className="font-medium">{row.label}</span>
|
<span className={row.fromDb ? "font-semibold" : "font-normal"}>
|
||||||
|
{row.label}
|
||||||
|
</span>
|
||||||
{row.inflation !== null ? (
|
{row.inflation !== null ? (
|
||||||
<span className="text-xs text-muted-foreground tabular-nums inline-flex items-center gap-1">
|
<span className="text-xs text-muted-foreground tabular-nums inline-flex items-center gap-1">
|
||||||
<TrendingUp className="size-3" />
|
<TrendingUp className="size-3" />
|
||||||
@@ -297,7 +308,11 @@ export function MonthlyVariationTable() {
|
|||||||
key={row.month}
|
key={row.month}
|
||||||
className="border-b last:border-0 hover:bg-muted/30"
|
className="border-b last:border-0 hover:bg-muted/30"
|
||||||
>
|
>
|
||||||
<td className="px-3 py-2.5 font-medium">{row.label}</td>
|
<td
|
||||||
|
className={`px-3 py-2.5 ${row.fromDb ? "font-semibold" : "font-normal"}`}
|
||||||
|
>
|
||||||
|
{row.label}
|
||||||
|
</td>
|
||||||
<td className="px-3 py-2.5 text-right">
|
<td className="px-3 py-2.5 text-right">
|
||||||
<VariationIndicator
|
<VariationIndicator
|
||||||
variation={row.BELO.variation}
|
variation={row.BELO.variation}
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ export type MonthlyLast = {
|
|||||||
month: string;
|
month: string;
|
||||||
type: "BELO" | "BLUE" | "BNA";
|
type: "BELO" | "BLUE" | "BNA";
|
||||||
buy: number;
|
buy: number;
|
||||||
|
source: "db" | "external";
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getMonthlyLast(): Promise<MonthlyLast[]> {
|
export function getMonthlyLast(): Promise<MonthlyLast[]> {
|
||||||
|
|||||||
Reference in New Issue
Block a user