-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fetch BOS indexerdata from near RPC call and conditionally render metadata if available in databricks #873
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
69a902c
fix: fixed indexerURL and myindexers
Kevin101Zhang 9f0d60c
chore
Kevin101Zhang aa20e8c
chore
Kevin101Zhang 7c264be
fix: conditionally render metadata and changed source of data back to…
Kevin101Zhang 3f43762
chore
Kevin101Zhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
const accountId = context.accountId; | ||
const santizedAccountId = accountId.replaceAll(".", "_"); | ||
const myAccountId = context.accountId; | ||
|
||
const [selectedTab, setSelectedTab] = useState(props.tab && props.tab !== "all" ? props.tab : "all"); | ||
const [myIndexers, setMyIndexers] = useState([]); | ||
const [allIndexers, setAllIndexers] = useState([]); | ||
const [error, setError] = useState(null); | ||
const [indexerMetadata, setIndexerMetaData] = useState(new Map()); | ||
|
||
const fetchIndexerData = () => { | ||
Near.asyncView(`${REPL_REGISTRY_CONTRACT_ID}`, "list_all").then((data) => { | ||
const allIndexers = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be replaced with indexer |
||
const myIndexers = []; | ||
Object.keys(data).forEach((accId) => { | ||
Object.keys(data[accId]).forEach((functionName) => { | ||
const indexer = { | ||
accountId: accId, | ||
indexerName: functionName, | ||
}; | ||
if (accId === myAccountId) myIndexers.push(indexer); | ||
allIndexers.push(indexer); | ||
}); | ||
}); | ||
setMyIndexers(myIndexers); | ||
setAllIndexers(allIndexers); | ||
}); | ||
} | ||
|
||
const storeIndexerMetaData = () => { | ||
const url = `${REPL_QUERY_API_USAGE_URL}`; | ||
|
||
asyncFetch(url) | ||
|
@@ -16,12 +35,10 @@ const fetchIndexerData = () => { | |
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
const { data } = JSON.parse(response.body); | ||
const allIndexers = []; | ||
const myIndexers = []; | ||
const map = new Map(); | ||
|
||
data.forEach(entry => { | ||
const { indexer_account_id, indexers } = entry; | ||
|
||
indexers.forEach(({ indexer_name, last_deployment_date, num_deployements, num_queries, original_deployment_date }) => { | ||
const indexer = { | ||
accountId: indexer_account_id, | ||
|
@@ -31,21 +48,17 @@ const fetchIndexerData = () => { | |
numQueries: num_queries, | ||
originalDeploymentDate: original_deployment_date | ||
}; | ||
|
||
if (indexer_account_id === santizedAccountId) myIndexers.push(indexer); | ||
allIndexers.push(indexer); | ||
map.set(`${indexer_account_id}/${indexer_name}`, indexer); | ||
}); | ||
}); | ||
|
||
setMyIndexers([myIndexers]); | ||
setAllIndexers(allIndexers); | ||
setIndexerMetaData(map); | ||
setError(null); | ||
}) | ||
} | ||
|
||
|
||
useEffect(() => { | ||
fetchIndexerData(); | ||
storeIndexerMetaData(); | ||
}, []); | ||
|
||
const Wrapper = styled.div` | ||
|
@@ -243,7 +256,7 @@ return ( | |
<Item key={i}> | ||
<Widget | ||
src={`${REPL_ACCOUNT_ID}/widget/QueryApi.IndexerCard`} | ||
props={{ ...indexer }} | ||
props={{ ...indexer, indexerMetadata }} | ||
/> | ||
</Item> | ||
))} | ||
|
@@ -271,7 +284,7 @@ return ( | |
<Item key={i}> | ||
<Widget | ||
src={`${REPL_ACCOUNT_ID}/widget/QueryApi.IndexerCard`} | ||
props={{ ...indexer }} | ||
props={{ ...indexer, indexerMetadata }} | ||
/> | ||
</Item> | ||
))} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this not necessary anymore? I think we use
active tab
in various places?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the state did not exist on the page. I assumed maybe it was a hidden property passed from a parent but i didnt see anything of the sort. Removing it I did not see any differences.