Skip to content

Commit

Permalink
Added indexer as alias in events committee (#899)
Browse files Browse the repository at this point in the history
* added indexer as alias

* fmt

* first 6 proposals don't show up in this indexer

* new indexer

* fmt

* fix: test
  • Loading branch information
Tguntenaar authored Jul 25, 2024
1 parent 8ecf64a commit 79df084
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
4 changes: 3 additions & 1 deletion instances/events-committee.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
"REPL_EFIZ": "efiz.near",
"REPL_DEVS": "devs.near",
"REPL_SOCIAL_CONTRACT": "social.near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org"
"REPL_RPC_URL": "https://rpc.mainnet.near.org",
"REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "thomasguntenaar_near_event_committee_prod_v1_proposals_with_latest_snapshot",
"REPL_INDEXER_HASURA_ROLE": "thomasguntenaar_near"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ const showAccountAutoComplete = props.showAutoComplete ?? false;
const showProposalIdAutoComplete = props.showProposalIdAutoComplete ?? false;
const autoFocus = props.autoFocus ?? false;

const queryName =
"thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot";
const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}";
const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) {
${queryName}(
offset: $offset
Expand Down Expand Up @@ -236,7 +235,7 @@ async function getSuggestedProposals(id) {
}
await asyncFetch("https://near-queryapi.api.pagoda.co/v1/graphql", {
method: "POST",
headers: { "x-hasura-role": "thomasguntenaar_near" },
headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" },
body: JSON.stringify({
query: query,
variables: variables,
Expand All @@ -246,7 +245,7 @@ async function getSuggestedProposals(id) {
.then((res) => {
const proposals =
res?.data?.[
"thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot"
"${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}"
];
results = proposals;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ const FeedPage = () => {
currentlyDisplaying: 0,
});

const queryName =
"thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot";
const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}";
const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) {
${queryName}(
offset: $offset
Expand Down Expand Up @@ -245,7 +244,7 @@ const FeedPage = () => {
function fetchGraphQL(operationsDoc, operationName, variables) {
return asyncFetch(QUERYAPI_ENDPOINT, {
method: "POST",
headers: { "x-hasura-role": `thomasguntenaar_near` },
headers: { "x-hasura-role": `${REPL_INDEXER_HASURA_ROLE}` },
body: JSON.stringify({
query: operationsDoc,
variables: variables,
Expand Down Expand Up @@ -332,12 +331,8 @@ const FeedPage = () => {
fetchGraphQL(query, "GetLatestSnapshot", variables).then(async (result) => {
if (result.status === 200) {
if (result.body.data) {
const data =
result.body.data
.thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot;
const totalResult =
result.body.data
.thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot_aggregate;
const data = result.body.data[queryName];
const totalResult = result.body.data[`${queryName}_aggregate`];
State.update({ aggregatedCount: totalResult.aggregate.count });
// Parse timeline
fetchBlockHeights(data, offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ const [selectedProposals, setSelectedProposals] = useState(linkedProposals);
const [proposalsOptions, setProposalsOptions] = useState([]);
const [searchProposalId, setSearchProposalId] = useState("");
const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql`;
const queryName =
"thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot";
const queryName = "${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}";
const query = `query GetLatestSnapshot($offset: Int = 0, $limit: Int = 10, $where: ${queryName}_bool_exp = {}) {
${queryName}(
offset: $offset
Expand Down Expand Up @@ -63,7 +62,7 @@ const buildWhereClause = () => {
function fetchGraphQL(operationsDoc, operationName, variables) {
return asyncFetch(QUERYAPI_ENDPOINT, {
method: "POST",
headers: { "x-hasura-role": `thomasguntenaar_near` },
headers: { "x-hasura-role": `${REPL_INDEXER_HASURA_ROLE}` },
body: JSON.stringify({
query: operationsDoc,
variables: variables,
Expand All @@ -83,8 +82,7 @@ const fetchProposals = () => {
if (result.status === 200) {
if (result.body.data) {
const proposalsData =
result.body.data
.thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot;
result.body.data["${REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME}"];

const data = [];
for (const prop of proposalsData) {
Expand Down
5 changes: 3 additions & 2 deletions playwright-tests/tests/events/proposals.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,10 @@ test.describe("Wallet is connected", () => {
// json.data.thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot.find(
// (proposal) => proposal.proposal_id === 2
// );

const json = {
data: {
thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot:
thomasguntenaar_near_event_committee_prod_v1_proposals_with_latest_snapshot:
[
{
author_id: "meghagoel.near",
Expand Down Expand Up @@ -598,7 +599,7 @@ test.describe("Wallet is connected", () => {
labels: [],
},
],
thomasguntenaar_near_events_committee_proposals_2_proposals_with_latest_snapshot_aggregate:
thomasguntenaar_near_event_committee_prod_v1_proposals_with_latest_snapshot_aggregate:
{
aggregate: {
count: 7,
Expand Down

0 comments on commit 79df084

Please sign in to comment.