this either fixes price charts or makes them backwards. lets see
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m23s
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m23s
This commit is contained in:
@@ -35,7 +35,8 @@ export default async function HashtagPage({ params, searchParams }: Props) {
|
||||
where: { tag },
|
||||
include: {
|
||||
priceHistory: {
|
||||
orderBy: { recordedAt: 'asc' },
|
||||
orderBy: { recordedAt: 'desc' },
|
||||
take: 192, // 192 updates = 2 days of 15-min intervals
|
||||
},
|
||||
_count: {
|
||||
select: { positions: true },
|
||||
@@ -153,7 +154,7 @@ export default async function HashtagPage({ params, searchParams }: Props) {
|
||||
<div className="bg-surface-card border border-surface-border rounded-xl p-4">
|
||||
<h2 className="text-sm font-medium text-slate-400 mb-4">Price History</h2>
|
||||
<PriceChart
|
||||
data={hashtag.priceHistory.map((p) => ({ ...p, recordedAt: p.recordedAt.toISOString() }))}
|
||||
data={hashtag.priceHistory.slice().reverse().map((p) => ({ ...p, recordedAt: p.recordedAt.toISOString() }))}
|
||||
height={280}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -88,7 +88,7 @@ export default async function PositionsPage({
|
||||
displayTag: true,
|
||||
currentPrice: true,
|
||||
priceHistory: {
|
||||
orderBy: { recordedAt: 'asc' },
|
||||
orderBy: { recordedAt: 'desc' },
|
||||
take: 20,
|
||||
select: { price: true },
|
||||
},
|
||||
@@ -148,7 +148,7 @@ export default async function PositionsPage({
|
||||
const costBasis = pos.avgBuyPrice * pos.shares
|
||||
const currentValue = pos.hashtag.currentPrice * pos.shares
|
||||
const pnlPct = costBasis > 0 ? (pnl / costBasis) * 100 : 0
|
||||
const sparkPrices = pos.hashtag.priceHistory.map((h) => h.price)
|
||||
const sparkPrices = pos.hashtag.priceHistory.slice().reverse().map((h) => h.price)
|
||||
return { ...pos, pnl, costBasis, currentValue, pnlPct, sparkPrices }
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user