diff --git a/instances/devhub.near/widget/app.jsx b/instances/devhub.near/widget/app.jsx
index 42f9044c6..14c1188c8 100644
--- a/instances/devhub.near/widget/app.jsx
+++ b/instances/devhub.near/widget/app.jsx
@@ -131,15 +131,6 @@ function Page() {
/>
);
}
- // ?page=feed
- case "feed": {
- return (
-
Loading modules...
; } -const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql/`; - -const queryName = - props.queryName ?? `bo_near_devhub_v38_posts_with_latest_snapshot`; -const totalQueryName = - props.totalQueryName ?? - "bo_near_devhub_v38_posts_with_latest_snapshot_aggregate"; -const query = `query DevhubPostsQuery($limit: Int = 100, $offset: Int = 0, $where: ${queryName}_bool_exp = {}) { - ${queryName}( - limit: $limit - offset: $offset - order_by: {ts: desc} - where: $where - ) { - post_id - } - } -`; - -const totalQuery = `query DevhubTotalPostsQuery($where: ${queryName}_bool_exp = {}) { - ${totalQueryName}( - where: $where - ) { - aggregate { - count - } - } - } -`; - -function fetchGraphQL(operationsDoc, operationName, variables) { - return asyncFetch(QUERYAPI_ENDPOINT, { - method: "POST", - headers: { "x-hasura-role": `bo_near` }, - body: JSON.stringify({ - query: operationsDoc, - variables: variables, - operationName: operationName, - }), - }); -} - function searchConditionChanged() { return ( props.author != state.author || @@ -83,98 +41,6 @@ State.init({ displayCount: initialRenderLimit, }); -function getPostIds(tag, offset) { - if (searchConditionChanged()) { - updateSearchCondition(); - } - let where = {}; - let authorId = props.author; - let label = tag || props.tag; - if (authorId) { - where = { author_id: { _eq: authorId }, ...where }; - } - if (props.term) { - where = { description: { _ilike: `%${props.term}%` }, ...where }; - } - if (label) { - if (typeof label === "string") { - // Handle a single label - where = { labels: { _contains: label }, ...where }; - } else if (Array.isArray(label)) { - // Handle an array of labels - where = { - labels: { - _containsAny: label, - }, - ...where, - }; - } - } - if (!props.recency) { - // show only top level posts - where = { parent_id: { _is_null: true }, ...where }; - } - - // Don't show blog and devhub-test posts - where = { - _and: [ - { - _not: { - labels: { _contains: "blog" }, - parent_id: { _is_null: true }, - post_type: { _eq: "Comment" }, - }, - }, - { - _not: { - labels: { _contains: "devhub-test" }, - }, - }, - ], - ...where, - }; - - if (!offset) { - fetchGraphQL(totalQuery, "DevhubTotalPostsQuery", { - where, - }).then((result) => { - const data = result.body.data[totalQueryName]; - State.update({ - totalItems: data.aggregate.count, - }); - }); - } - - fetchGraphQL(query, "DevhubPostsQuery", { - limit: 50, - offset: offset ?? 0, - where, - }).then((result) => { - if (result.status === 200) { - if (result.body.data) { - const data = result.body.data[queryName]; - if (offset) { - State.update({ - postIds: state.postIds.concat(data.map((p) => p.post_id)), - loading: false, - }); - } else { - State.update({ - postIds: data.map((p) => p.post_id), - loading: false, - }); - } - } - } else { - State.update({ loading: false }); - } - }); -} - -if (!state.items || searchConditionChanged()) { - getPostIds(); -} - function defaultRenderItem(postId, additionalProps) { if (!additionalProps) { additionalProps = {}; @@ -198,7 +64,6 @@ function defaultRenderItem(postId, additionalProps) { if (typeof props.updateTagInput === "function") { props.updateTagInput(tag); } - getPostIds(tag); }, transactionHashes: props.transactionHashes, }} @@ -271,10 +136,7 @@ const initialItems = postIds; const jInitialItems = JSON.stringify(initialItems); if (state.jInitialItems !== jInitialItems) { - // const jIndex = JSON.stringify(index); - // if (jIndex !== state.jIndex) { State.update({ - jIndex, jInitialItems, items: initialItems, cachedItems: {}, @@ -290,7 +152,6 @@ const makeMoreItems = () => { !state.loading ) { State.update({ loading: true }); - getPostIds(null, state.items.length); } }; diff --git a/instances/infrastructure-committee.near/aliases.mainnet.json b/instances/infrastructure-committee.near/aliases.mainnet.json index d23768897..0601bb07a 100644 --- a/instances/infrastructure-committee.near/aliases.mainnet.json +++ b/instances/infrastructure-committee.near/aliases.mainnet.json @@ -5,10 +5,5 @@ "REPL_NEAR": "near", "REPL_RPC_URL": "https://rpc.mainnet.near.org", "REPL_RFP_IMAGE": "https://ipfs.near.social/ipfs/bafkreicbygt4kajytlxij24jj6tkg2ppc2dw3dlqhkermkjjfgdfnlizzy", - "REPL_RFP_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_rfps_with_latest_snapshot", - "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_CACHE_URL": "https://infra-cache-api-rs.fly.dev" } diff --git a/instances/infrastructure-committee.near/widget/core/common.jsx b/instances/infrastructure-committee.near/widget/core/common.jsx index de2352d68..e1ed6b402 100644 --- a/instances/infrastructure-committee.near/widget/core/common.jsx +++ b/instances/infrastructure-committee.near/widget/core/common.jsx @@ -16,7 +16,6 @@ const PROPOSAL_TIMELINE_STATUS = { FUNDED: "FUNDED", }; -const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql`; const cacheUrl = "https://infra-cache-api-rs.fly.dev"; /** @@ -65,15 +64,49 @@ function searchCacheApi(entity, searchTerm) { }); } -async function fetchGraphQL(operationsDoc, operationName, variables) { - return asyncFetch(QUERYAPI_ENDPOINT, { - method: "POST", - headers: { "x-hasura-role": "${REPL_INDEXER_HASURA_ROLE}" }, - body: JSON.stringify({ - query: operationsDoc, - variables: variables, - operationName: operationName, - }), +/** + * Get proposals or rfps from cache api + * @param {proposals | rfps} entity + * @param {order, limit, offset, author_id, stage, category} variables + * @returns result.records, result.total_records, result.total_pages + */ +function fetchCacheApi(entity, variables) { + console.log("Fetching cache api", variables); + + let fetchUrl = `${cacheUrl}/${entity}?order=${variables.order}&limit=${variables.limit}&offset=${variables.offset}`; + + if (variables.author_id) { + fetchUrl += `&filters.author_id=${variables.author_id}`; + } + if (variables.stage) { + fetchUrl += `&filters.stage=${variables.stage}`; + } + if (variables.category) { + // Devhub uses category, infra uses labels + fetchUrl += `&filters.labels=${variables.category}`; + } + console.log("Fetching.. from infra common", fetchUrl); + return asyncFetch(fetchUrl, { + method: "GET", + headers: { + accept: "application/json", + }, + }).catch((error) => { + console.log("Error fetching cache api", error); + }); +} + +function searchCacheApi(entity, searchTerm) { + let searchInput = encodeURI(searchTerm); + let searchUrl = `${cacheUrl}/${entity}/search/${searchInput}`; + + return asyncFetch(searchUrl, { + method: "GET", + headers: { + accept: "application/json", + }, + }).catch((error) => { + console.log(`Error searching cache api in entity ${entity}:`, error); }); } @@ -117,7 +150,6 @@ function getLinkUsingCurrentGateway(url) { return { RFP_TIMELINE_STATUS, PROPOSAL_TIMELINE_STATUS, - fetchGraphQL, CANCEL_RFP_OPTIONS, parseJSON, isNumber, diff --git a/playwright-tests/tests/events/proposals.spec.js b/playwright-tests/tests/events/proposals.spec.js index 828867ac5..23ec8c33f 100644 --- a/playwright-tests/tests/events/proposals.spec.js +++ b/playwright-tests/tests/events/proposals.spec.js @@ -691,6 +691,7 @@ test.describe("Wallet is connected", () => { test("should filter proposals by author", async ({ page }) => { test.setTimeout(60000); const accountId = "yarotska.near"; + const profileName = "yarotska"; await page.getByRole("button", { name: "Author" }).click(); await page.getByRole("list").getByText(accountId).click(); await expect( @@ -698,7 +699,9 @@ test.describe("Wallet is connected", () => { ).toBeVisible(); const loader = page.getByRole("img", { name: "loader" }); expect(loader).toBeHidden({ timeout: 10000 }); - await expect(page.getByText(`By ${accountId} ・`).first()).toBeVisible(); + await expect( + page.getByText(`By ${profileName ?? accountId} ・`).first() + ).toBeVisible(); }); test("should filter proposals by search text", async ({ page }) => { diff --git a/playwright-tests/tests/sunset/blog.spec.js b/playwright-tests/tests/sunset/blog.spec.js index 814fad094..858b245bb 100644 --- a/playwright-tests/tests/sunset/blog.spec.js +++ b/playwright-tests/tests/sunset/blog.spec.js @@ -1,6 +1,6 @@ import { expect, test } from "@playwright/test"; -test.describe("Sunset Blog addon", () => { +test.skip("Sunset Blog addon", () => { test.use({ baseURL: "http://localhost:8080", }); @@ -63,7 +63,7 @@ test.describe("Sunset Blog addon", () => { }); }); -test.describe("Sunset Blog Addon", () => { +test.skip("Sunset Blog Addon", () => { test.use({ baseURL: "http://localhost:8080", }); diff --git a/playwright-tests/tests/sunset/create.spec.js b/playwright-tests/tests/sunset/create.spec.js index a36d41ad4..13cf2080b 100644 --- a/playwright-tests/tests/sunset/create.spec.js +++ b/playwright-tests/tests/sunset/create.spec.js @@ -32,7 +32,7 @@ test.describe("Wallet is connected", () => { storageState: "playwright-tests/storage-states/wallet-connected.json", }); - test("should be able to submit a solution (funding request) with USDC as currency", async ({ + test.skip("should be able to submit a solution (funding request) with USDC as currency", async ({ page, }) => { test.setTimeout(120000); diff --git a/playwright-tests/tests/sunset/feed.spec.js b/playwright-tests/tests/sunset/feed.spec.js index 49b0efa8d..a49c0349b 100644 --- a/playwright-tests/tests/sunset/feed.spec.js +++ b/playwright-tests/tests/sunset/feed.spec.js @@ -92,7 +92,7 @@ test.describe("Wallet is connected", () => { }); }); - test("successful idea reply post should not show the editor", async ({ + test.skip("successful idea reply post should not show the editor", async ({ page, }) => { await page.goto( @@ -105,7 +105,7 @@ test.describe("Wallet is connected", () => { }); }); - test("successful comment post should not show the editor", async ({ + test.skip("successful comment post should not show the editor", async ({ page, }) => { await page.goto( @@ -118,7 +118,7 @@ test.describe("Wallet is connected", () => { }); }); - test("successful edited post should not show the editor", async ({ + test.skip("successful edited post should not show the editor", async ({ page, }) => { await page.goto(