Skip to content

Commit 8f74215

Browse files
committed
update dune api
1 parent 9b97e9d commit 8f74215

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

apps/nextjs/src/app/api/dune/route.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,39 @@ export async function GET(request: Request) {
1414
const queryID = 4101280;
1515

1616
try {
17-
/*const executionResult = await client.getLatestResult({ queryId: queryID });
17+
const executionResult = await client.getLatestResult({ queryId: queryID });
1818
console.log(executionResult.result?.rows);
1919
if (executionResult.result?.rows) {
2020
// Filter and transform the rows to match schema
2121
const filteredRows = executionResult.result.rows.map(
2222
(row: Record<string, unknown>) => ({
2323
source: row.Name as string,
24-
amount: Number(row.amount),
25-
block_time: new Date(row.block_time),
26-
epoch: row.epoch ? new Date(row.epoch) : null,
27-
epoch_total_amount: Number(row.epoch_total_amount),
28-
sender_epoch_total_amount: row.sender_epoch_total_amount
29-
? Number(row.sender_epoch_total_amount)
30-
: 0,
24+
amount: row.amount as string,
25+
//block_time: new Date(row.block_time),
26+
//epoch: row.epoch ? new Date(row.epoch) : null,
27+
epoch_total_amount: row.epoch_total_amount as string,
28+
sender_epoch_total_amount: row.sender_epoch_total_amount as string,
3129
}),
32-
) satisfies (typeof schema.duneVelords.$inferInsert)[];
33-
console.log(filteredRows[0]);*/
30+
) satisfies (typeof schema.velords_burns.$inferInsert)[];
31+
console.log(filteredRows[0]);
3432

35-
try {
36-
const tokenAttributeResult = await db
37-
.insert(schema.velords_burns)
38-
.values([{ source: "test" }])
39-
.returning({
40-
source: schema.velords_burns.source,
41-
//amount: schema.duneVelords.amount,
42-
//epoch: schema.duneVelords.epoch,
43-
});
33+
try {
34+
const tokenAttributeResult = await db
35+
.insert(schema.velords_burns)
36+
.values(filteredRows)
37+
.returning({
38+
source: schema.velords_burns.source,
39+
amount: schema.velords_burns.amount,
40+
//epoch: schema.velords_burns.epoch,
41+
});
4442

45-
console.log(tokenAttributeResult);
43+
console.log(tokenAttributeResult);
4644

47-
return new Response(JSON.stringify(tokenAttributeResult));
48-
} catch (e) {
49-
console.log(e);
50-
return new Response(JSON.stringify(e));
45+
return new Response(JSON.stringify(tokenAttributeResult));
46+
} catch (e) {
47+
console.log(e);
48+
return new Response(JSON.stringify(e));
49+
}
5150
}
5251
} catch (error) {
5352
console.error(error);

0 commit comments

Comments
 (0)