This commit is contained in:
Elijah McMorris 2024-02-19 08:58:07 -08:00
parent b0f3e6c576
commit e44d419b58
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
15 changed files with 233 additions and 82 deletions

View file

@ -1,18 +1,30 @@
"use server";
import { initConnection } from "@/components/db-utils";
import { initConnectionPostgres, initConnectionSurreal } from "@/components/db-utils";
export async function querydb() {
try {
let db = await initConnection();
// console.log(db);
let stats = await db.query(`
select * from url
order by clicks desc
limit 50;
`);
let stats = [];
if (process.env.DB_TYPE === "surrealdb") {
let db = await initConnectionSurreal();
// console.log(db);
stats = await db.query(`
select * from url
order by clicks desc
limit 50;
`);
// @ts-ignore
stats = stats[0];
// @ts-ignore
stats = stats[0];
}
if (process.env.DB_TYPE === "postgres") {
let sql = await initConnectionPostgres();
stats = await sql`
select * from url
order by clicks desc
limit 50;
`;
}
return stats;
} catch (e) {

View file

@ -8,7 +8,7 @@ import {
export default function Loading() {
return (
<CardGrid max_rows={1}>
<CardGrid maxCols={1}>
<Card>
<CardHeader>
<CardTitle className="text-1xl text-amber-400">Loading...</CardTitle>

View file

@ -44,7 +44,7 @@ export default function StatsPage() {
return data.length === 0 ? (
<Loading />
) : (
<CardGrid max_rows={1}>
<CardGrid maxCols={1}>
<Card>
{/* @ts-ignore */}
<DataTable columns={columns} data={data} />