Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Tguntenaar committed Nov 13, 2024
1 parent b5e9375 commit 48d8365
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
3 changes: 2 additions & 1 deletion instances/devhub.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"REPL_RPC_URL": "https://rpc.mainnet.near.org",
"REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_prod_v1_proposals_with_latest_snapshot",
"REPL_INDEXER_HASURA_ROLE": "polyprogrammist_near",
"REPL_POSTHOG_API_KEY": "01234567890123456789012345678901234567890123456"
"REPL_POSTHOG_API_KEY": "01234567890123456789012345678901234567890123456",
"REPL_CACHE_URL": "https://devhub-cache-api-rs.fly.dev"
}
30 changes: 15 additions & 15 deletions instances/devhub.near/widget/devhub/entity/proposal/Feed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,20 @@ const FeedPage = () => {
fetchProposals(state.data.length);
};

/**
* { name: { _iregex: `${text}` } },
{ summary: { _iregex: `${text}` } },
{ descriptio
*/

function fetchCacheApi(variables) {
// TODO: move to config
const ENDPOINT = "https://devhub-cache-api-rs.fly.dev";
const ENDPOINT = "${REPL_CACHE_URL}";
console.log("Fetching endpoint", ENDPOINT);
console.log("Fetching cache api", variables);

return asyncFetch(
`${ENDPOINT}/proposals?offset=${variables.offset}&limit=${variables.limit}&stage=${variables.stage}&author_id=${variables.author_id}&category=${variables.category}`,
`${ENDPOINT}/proposals?\
order=${variables.sort}\
&limit=${variables.limit}\
&offset=${variables.offset}\
&filters.category=${variables.category}\
&filters.labels=${variables.labels}\
&filters.author_id=${variables.author_id}\
&filters.stage=${variables.stage}`,
{
method: "GET",
headers: {
Expand All @@ -421,20 +422,21 @@ const FeedPage = () => {
State.update({ loading: true });
const FETCH_LIMIT = 10;
const variables = {
order: state.sort,
limit: FETCH_LIMIT,
offset,
category: state.category,
labels: state.labels,
author_id: state.author,
stage: state.stage,
category: state.category,
};
fetchCacheApi(variables).then((result) => {
console.log("result", result);
let data = result.body.records;
let totalResult = { aggregate: { count: data.length } }; // TODO
let totalResult = { aggregate: { count: result.body.total_records } }; // TODO

const promises = data.map((item) => {
if (isNumber(item.linked_rfp)) {
return; // TODO index RFPs
fetchGraphQL(rfpQuery, "GetLatestSnapshot", {
where: { rfp_id: { _eq: item.linked_rfp } },
}).then((result) => {
Expand Down Expand Up @@ -462,10 +464,8 @@ const FeedPage = () => {
...new Set([...newItems, ...state.data].map((i) => JSON.stringify(i))),
].map((i) => JSON.parse(i));
// Sorting in the front end
if (state.sort === "proposal_id" || state.sort === "") {
if (state.sort === "id_desc" || state.sort === "") {
items.sort((a, b) => b.proposal_id - a.proposal_id);
} else if (state.sort === "views") {
items.sort((a, b) => b.views - a.views);
}

return items;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
const options = [
{ label: "All", value: "" },
{ label: "Most recent", value: "proposal_id" }, // proposal_id desc
{ label: "Most viewed", value: "views" }, // views desc
// TODO add track_comments function to devhub to track it in the indexer
// { label: "Most commented", value: "" }, // comments desc
// { label: "Unanswered", value: "" }, // where comments = 0
// where comments = 0
{ label: "Most recent", value: "id_desc" }, // proposal_id desc
{ label: "Oldest", value: "id_asc" }, // proposal_id desc
{ label: "Recently updated", value: "ts_desc" }, // timestamp desc
{ label: "Least recently updated", value: "ts_asc" }, // timestamp asc
];

const setSelected = props.onStateChange ?? (() => {});
Expand Down
3 changes: 2 additions & 1 deletion instances/events-committee.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"REPL_SOCIAL_CONTRACT": "social.near",
"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"
"REPL_INDEXER_HASURA_ROLE": "thomasguntenaar_near",
"REPL_CACHE_URL": "https://events-cache-api-rs.fly.dev"
}
3 changes: 2 additions & 1 deletion instances/infrastructure-committee.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"REPL_RFP_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_rfp_snapshots",
"REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposals_with_latest_snapshot",
"REPL_PROPOSAL_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposal_snapshots",
"REPL_INDEXER_HASURA_ROLE": "polyprogrammist_near"
"REPL_INDEXER_HASURA_ROLE": "polyprogrammist_near",
"REPL_CACHE_URL": "https://infra-cache-api-rs.fly.dev"
}

0 comments on commit 48d8365

Please sign in to comment.