Skip to content

Commit

Permalink
edit inngest build query
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBeardEth committed Dec 15, 2023
1 parent da34ccb commit 1164062
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
10 changes: 5 additions & 5 deletions apps/nextjs/src/app/collection/[id]/(list)/L2ERC721Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,22 @@ const GridDetails = ({
token={token}
attributeKeys={["type", "tier", "level", "health"]}
/>
<Price listing={token?.listings?.[0]} />
<Price token={token} />
<div className="mt-3 text-xs opacity-70">{starkName}</div>
</div>
);

const Price = ({
listing,
token,
}: {
listing: RouterOutputs["erc721Tokens"]["all"]["items"][number]["listings"][number];
token: RouterOutputs["erc721Tokens"]["all"]["items"][number];
}) => {
return (
<div className="flex justify-between">
{listing?.price && (
{token?.price && (
<div>
<h6 className="uppercase">Price</h6>
<div>{listing?.price}</div>
<div>{token?.price}</div>
</div>
)}
<div>
Expand Down
11 changes: 7 additions & 4 deletions apps/nextjs/src/inngest/fetch_metadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextResponse } from "next/server";
import { hash, shortString, uint256 } from "starknet";

import { db, eq, schema } from "@realms-world/db";
import { and, db, eq, schema, sql } from "@realms-world/db";

import { getTokenContractAddresses } from "../utils/utils";
//import { Client } from "https://esm.sh/ts-postgres";
Expand Down Expand Up @@ -101,9 +101,12 @@ export const fetchMetadata = inngest.createFunction(
metadata: { attributes: parsedJson.attributes },
})
.where(
eq(
schema.erc721Tokens.id,
event.data.contract_address + ":" + event.data.tokenId,
and(
eq(
schema.erc721Tokens.id,
event.data.contract_address + ":" + event.data.tokenId,
),
sql`upper_inf(_cursor)`,
),
)
.returning({ updatedId: schema.erc721Tokens.id });
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/router/erc721Tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export const erc721TokensRouter = createTRPCRouter({
const orderByFilter: SQL[] = [];
const orderByVariable =
orderBy == "floorAskPrice"
? schema.erc721Tokens.listings
? schema.erc721Tokens.price
: schema.erc721Tokens.token_id;
if (direction === "asc") {
orderByFilter.push(asc(schema.erc721Tokens.token_id));
orderByFilter.push(asc(orderByVariable));
} else {
orderByFilter.push(desc(schema.erc721Tokens.token_id));
orderByFilter.push(desc(orderByVariable));
}

if (contractAddress) {
Expand Down
4 changes: 2 additions & 2 deletions packages/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (!process.env.VERCEL_ENV) {

neonConfig.fetchConnectionCache = true;

export const sql = neon(process.env.DATABASE_URL!);
export const neonSql = neon(process.env.DATABASE_URL!);
//const queryClient = postgres('postgres://postgres:postgres@localhost:5432');

export const db = drizzle(sql, { schema });
export const db = drizzle(neonSql, { schema });

0 comments on commit 1164062

Please sign in to comment.