Skip to content

Commit

Permalink
update api
Browse files Browse the repository at this point in the history
update
  • Loading branch information
RedBeardEth committed Jan 6, 2025
1 parent 5664fb0 commit 8ca622d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
5 changes: 2 additions & 3 deletions apps/nextjs/src/app/api/dune/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export async function GET(request: Request) {

try {
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(
Expand All @@ -23,12 +22,12 @@ export async function GET(request: Request) {
amount: row.amount as string,
transaction_hash: row.transaction_hash as string,
//block_time: new Date(row.block_time),
epoch: new Date(row.epoch as string),
epoch: row.epoch as Date,
epoch_total_amount: row.epoch_total_amount as string,
sender_epoch_total_amount: row.sender_epoch_total_amount as string,
}),
) satisfies (typeof schema.velords_burns.$inferInsert)[];
console.log(filteredRows[0]);
console.log(filteredRows);

try {
const tokenAttributeResult = await db
Expand Down
14 changes: 7 additions & 7 deletions packages/api/src/router/veLordsBurns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ export const veLordsBurnsRouter = {
.query(({ ctx, input }) => {
const { sender, startTimestamp, endTimestamp } = input;
const whereFilter: SQL[] = sender
? [eq(velords_burns2.sender, sender.toLowerCase())]
? [eq(velords_burns.source, sender.toLowerCase())]
: [];

if (startTimestamp) {
whereFilter.push(gte(velords_burns2.timestamp, startTimestamp));
/*if (startTimestamp) {
whereFilter.push(gte(velords_burns.timestamp, startTimestamp));
}
if (endTimestamp) {
whereFilter.push(lte(velords_burns2.timestamp, endTimestamp));
}
whereFilter.push(lte(velords_burns.timestamp, endTimestamp));
}*/

return ctx.db.query.velords_burns2.findMany({
return ctx.db.query.velords_burns.findMany({
where: and(...whereFilter),
orderBy: desc(velords_burns2.timestamp),
//orderBy: desc(velords_burns.timestamp),
});
}),

Expand Down
5 changes: 4 additions & 1 deletion packages/db/src/schema/dune_velords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export const velords_burns = pgTable(
amount: numeric("amount").notNull(),
transaction_hash: text("transaction_hash").notNull(),
//block_time: timestamp("block_time").notNull(),
//epoch: timestamp("epoch"),
epoch: timestamp("epoch", {
mode: "date",
precision: 3,
}).notNull(),
epoch_total_amount: numeric("epoch_total_amount").notNull(),
sender_epoch_total_amount: numeric("sender_epoch_total_amount").notNull(),
},
Expand Down

0 comments on commit 8ca622d

Please sign in to comment.