Skip to content

Commit

Permalink
update dune api
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBeardEth committed Jan 5, 2025
1 parent 9b97e9d commit 8f74215
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions apps/nextjs/src/app/api/dune/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,39 @@ export async function GET(request: Request) {
const queryID = 4101280;

try {
/*const executionResult = await client.getLatestResult({ queryId: queryID });
const executionResult = await client.getLatestResult({ queryId: queryID });
console.log(executionResult.result?.rows);
if (executionResult.result?.rows) {
// Filter and transform the rows to match schema
const filteredRows = executionResult.result.rows.map(
(row: Record<string, unknown>) => ({
source: row.Name as string,
amount: Number(row.amount),
block_time: new Date(row.block_time),
epoch: row.epoch ? new Date(row.epoch) : null,
epoch_total_amount: Number(row.epoch_total_amount),
sender_epoch_total_amount: row.sender_epoch_total_amount
? Number(row.sender_epoch_total_amount)
: 0,
amount: row.amount as string,
//block_time: new Date(row.block_time),
//epoch: row.epoch ? new Date(row.epoch) : null,
epoch_total_amount: row.epoch_total_amount as string,
sender_epoch_total_amount: row.sender_epoch_total_amount as string,
}),
) satisfies (typeof schema.duneVelords.$inferInsert)[];
console.log(filteredRows[0]);*/
) satisfies (typeof schema.velords_burns.$inferInsert)[];
console.log(filteredRows[0]);

try {
const tokenAttributeResult = await db
.insert(schema.velords_burns)
.values([{ source: "test" }])
.returning({
source: schema.velords_burns.source,
//amount: schema.duneVelords.amount,
//epoch: schema.duneVelords.epoch,
});
try {
const tokenAttributeResult = await db
.insert(schema.velords_burns)
.values(filteredRows)
.returning({
source: schema.velords_burns.source,
amount: schema.velords_burns.amount,
//epoch: schema.velords_burns.epoch,
});

console.log(tokenAttributeResult);
console.log(tokenAttributeResult);

return new Response(JSON.stringify(tokenAttributeResult));
} catch (e) {
console.log(e);
return new Response(JSON.stringify(e));
return new Response(JSON.stringify(tokenAttributeResult));
} catch (e) {
console.log(e);
return new Response(JSON.stringify(e));
}
}
} catch (error) {
console.error(error);
Expand Down

0 comments on commit 8f74215

Please sign in to comment.