17 Active Allocations Data From Subgraph
# get list of current allocations (again)
'{
query = allocations(where: {indexer:"0x74dbb201ecc0b16934e68377bc13013883d9417b", status: Active}, first:1000) {
id
status
allocatedTokens
createdAtEpoch
subgraphDeployment {
ipfsHash
}
}
}'
# Send POST request to the GraphQL API
POST(url, body = list(query = query), encode = "json")
response =# Parse the JSON response
content(response, "text", encoding='UTF-8')
content = fromJSON(content, flatten = TRUE)
json_data =# get list of current allocations
as_tibble(as.data.frame(json_data$data$allocations))
current_allocations =if (nrow(current_allocations) ){
# add ipfs hash
$deployment = json_data$data$allocations$subgraphDeployment.ipfsHash
current_allocations# remove old nested column
%<>% select(-subgraphDeployment.ipfsHash)
current_allocations # adjust allocatedTokens (just to avoid any confusion or issues)
$allocatedTokens = as.numeric(current_allocations$allocatedTokens)/10^18
current_allocations }
Would be better to change this where we do a before and after and decide which ones to not close:
# TEMP REMOVED - NEED TO UNCOMMENT THIS OUT!
# Now exclude from synced_subgraphs those that are already allocated on:
#synced_subgraphs = anti_join(synced_subgraphs, current_allocations, by = "deployment")
save.image('/root/github/indexer_analytics_tutorial/data/chapters_snapshots/09-active_allocations.RData')