Published
Edited
Sep 22, 2019
Insert cell
Insert cell
channelId = "f19015f5-55d8-4fd6-8621-df79ac072e15"
Insert cell
userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1Njg2NDg0MTAsImV4cCI6MTU3MTMyNjgxMCwiaXNzIjoiRm9yZXRvbGQiLCJzdWIiOiIwNTQzZDlkNC1kYjM5LTQ3ZWEtYWNjNy00YzFiYTBlOWVkMGIifQ.a4cNuKibtqYGUWDlen8o-5lWQmk6q7q36DNBKuMYwyg"
Insert cell
Insert cell
organized = {
let measurables = _.uniq(agentPredictions.map(p => p.measurable.name));
let people = _.uniq(agentPredictions.map(p => p.agent.name));
let predictions = measurables.map(m => people.map(p => agentPredictions.find(r => r.measurable.name === m && r.agent.name ===p)))
return {measurables, people, predictions};
}
Insert cell
foretoldData = {
const fetchForetoldData = async () => {
const res = await fetch('https://prediction-backend.herokuapp.com/graphql', {
headers: {'Content-Type': 'application/json',
"Authorization":`Bearer ${userToken}` },
method: 'POST',
body: JSON.stringify({ query: query })
});
return res;
}
const fetchedData = await fetchForetoldData();
const formattedData = await fetchedData.json();

return formattedData;
}
Insert cell
agentPredictions = foretoldData.data.agentMeasurables.edges.map(r => r.node)
Insert cell
Insert cell
_ = require("lodash")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more