Skip to content

Instantly share code, notes, and snippets.

@ccamel
Last active October 4, 2024 12:13
Show Gist options
  • Save ccamel/f27603e36d7b4e6f2bfc5c5454f71cdd to your computer and use it in GitHub Desktop.
Save ccamel/f27603e36d7b4e6f2bfc5c5454f71cdd to your computer and use it in GitHub Desktop.
Simple magical one-line bash command to graph KatAI contributions over time (https://katai.xyz)
( export NODE="https://api.dentrite.axone.xyz:443/rpc"; \
export CONTRACT="axone1xa8wemfrzq03tkwqxnv9lun7rceec7wuhh8x3qjgxkaaj5fl50zsmj8u0n"; \
axoned query wasm contract-state smart \
"$CONTRACT" \
'{
"select": {
"query": {
"prefixes": [],
"select": [
{ "variable": "date" }
],
"where": {
"lateral_join": {
"left": {
"filter": {
"expr": {
"greater_or_equal": [
{"variable": "timestamp"},
{"literal": {"simple": "1727607649"}}
]
},
"inner": {
"bgp": {
"patterns": [
{
"subject": { "variable": "credPub" },
"predicate": {
"named_node": { "full": "dataverse:credential:body#type" }
},
"object": {
"node": {
"named_node": {
"full": "https://w3id.org/axone/ontology/v4/schema/credential/digital-resource/publication/DigitalResourcePublicationCredential"
}
}
}
},
{
"subject": { "variable": "credPub" },
"predicate": {
"named_node": { "full": "dataverse:credential:body#issuer" }
},
"object": {
"node": {
"named_node": {
"full": "did:key:zQ3sheahWxVvKeNjKLvK5gF1zk22UVJHT6NEnTp8w7vKiMv2d"
}
}
}
},
{
"subject": { "variable": "credPub" },
"predicate": {
"named_node": { "full": "dataverse:credential:header#timestamp" }
},
"object": { "variable": "timestamp" }
}
]
}
}
}
},
"right": {
"bgp": {
"patterns": [
{
"subject": { "variable": "credPub" },
"predicate": {
"named_node": { "full": "dataverse:credential:body#validFrom" }
},
"object": { "variable": "date" }
}
]
}
}
}
}
}
}
}' \
--node "$NODE" \
-ojson \
| jq -r -c '.data.results.bindings[].date.value' \
| sort \
| uniq -c \
| awk '{print $2, $1}' \
| gnuplot -e 'set terminal dumb size 130, 30;
set autoscale;
set xdata time;
set timefmt "%Y-%m-%dT%H:%M:%S";
set title "KatAI contributions";
set xlabel "Date";
set ylabel "Count";
cumulative_sum(x)=(count=count+x,count);
count=0;
plot "-" using 1:(cumulative_sum($2)) title "" with lines;'
)
KatAI contributions
3000 +-------------------------------------------------------------------------------------------------------------------+
| + + + + + |
| **** |
| ** |
2500 |-+ ******** +-|
| ** |
| ** |
| ************** |
2000 |-+ ** +-|
| ********* |
| *** |
1500 |-+ ******** +-|
Count | ** |
| ** |
| ************** |
1000 |-+ *** +-|
| *********** |
| * |
| ****************** |
500 |-+ ** +-|
| ** |
| ** |
| ** + + + + + |
0 +-------------------------------------------------------------------------------------------------------------------+
04/01 05/01 06/01 07/01 08/01 09/01 10/01
Date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment