Skip to content

Commit

Permalink
chore(profile): Get subgraph by function
Browse files Browse the repository at this point in the history
  • Loading branch information
chef-huan committed May 27, 2024
1 parent c8bcf5d commit c15424f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/users/search.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VercelRequest, VercelResponse } from "@vercel/node";
import { gql, request } from "graphql-request";
import { Parser } from "json2csv";
import { PROFILE_SUBGRAPH } from "../../utils";
import { getProfileSubgraph } from "../../utils";

type User = {
id: string;
Expand Down Expand Up @@ -35,7 +35,7 @@ const getUsersFirstPage = async (
const isActiveBool = isActive && isActive.toLowerCase() === "true";

const { users } = await request(
PROFILE_SUBGRAPH,
getProfileSubgraph(),
gql`
query getUsersQuery($pageSize: Int, $team: String, $totalPointGT: String, $totalPointLT: String,
$totalPointGTE: String, $totalPointLTE: String, $nftAddress: String, $lastUserId: String, $isActiveBool: Boolean) {
Expand Down
9 changes: 7 additions & 2 deletions utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import blacklist from "./blacklist.json";
import { getModel } from "./mongo";

export const PROFILE_SUBGRAPH =
process.env.PROFILE_SUBGRAPH_URL || "https://api.thegraph.com/subgraphs/name/pancakeswap/profile";
export const getProfileSubgraph = (): string => {
const profileSubgraphUrl = process.env.PROFILE_SUBGRAPH_URL;
if (profileSubgraphUrl) {
return profileSubgraphUrl;
}
throw Error(`Profile subgraph URL is not set ${profileSubgraphUrl}`);
};

/**
* Check for the validity of a username based on rules (see documentation).
Expand Down

0 comments on commit c15424f

Please sign in to comment.