--- import ebay from "/vendors/ebay.svg?raw"; import SetIcon from '../../components/SetIcon.astro'; import EnergyIcon from '../../components/EnergyIcon.astro'; import RarityIcon from '../../components/RarityIcon.astro'; import { db } from '../../db/index.ts'; import { privateDecrypt } from "node:crypto"; import latestSales from '../../sampleData/latestsales.json'; import chartdata from '../../sampleData/chartdata.json'; const priceData = chartdata; export const partial = true; export const prerender = false; const searchParams = Astro.url.searchParams; const productId = Number(searchParams.get('productId')) || 0; // query the database for the card with the given productId and return the card data as json const card = await db.query.cards.findFirst({ where: { productId: Number(productId) }, with: { prices: true, set: true, } }); const nearMint = await db.query.skus.findFirst({ where: { productId: Number(productId), } }); const nearMintPrice = nearMint?.marketPrice ?? null; const calculatedAt = new Date(nearMint?.calculatedAt || 0); function timeAgo(date: any) { if (date==0) return "never"; const seconds = Math.floor((Date.now() - date) / 1000); const intervals = { year: 31536000, month: 2592000, day: 86400, hour: 3600, minute: 60 }; for (const [unit, value] of Object.entries(intervals)) { const count = Math.floor(seconds / value); if (count >= 1) return `${count} ${unit}${count > 1 ? "s" : ""} ago`; } return "just now"; } ---