Fix pitchmap ui demo

This broke when we changed from heads to a single head
This commit is contained in:
Erik Arvidsson
2015-08-25 13:05:00 -04:00
parent 1d152410db
commit e9efeb6115
2 changed files with 21 additions and 28 deletions

View File

@@ -5,15 +5,12 @@ var React = require('react');
var Map = require('./map.js');
noms.getDataset('mlb/heatmap')
.then(getPitchers)
.then(renderPitchersList);
.then(getPitchers)
.then(renderPitchersList);
function getPitchers(datasetRoot) {
return datasetRoot.deref().then((root) => {
return root.first().deref();
}).then((map) =>{
return map.get('value').deref();
});
function getPitchers(datasetRootRef) {
return datasetRootRef.deref()
.then(datasetRoot => datasetRoot.get('value').deref());
}
var PitcherList = React.createClass({

View File

@@ -3,30 +3,27 @@ var decode = require('./decode.js')
function getDataset(id) {
return store.getRoot()
.then(rootRef => decode.readValue(rootRef, store.getChunk))
.then(root => root.deref())
.then(heads => heads.first().deref())
.then(commit => commit.get('value').deref())
.then(dsRefs => Promise.all(dsRefs.map(ref => ref.deref())))
.then(datasets =>
{
var match = datasets.filter(dataset => dataset.get('id') == id);
if (match.length > 1) {
throw Error("Um...this can't be good: More than one dataset with id " + id);
}
.then(rootRef => decode.readValue(rootRef, store.getChunk))
.then(root => root.deref())
.then(commit => commit.get('value').deref())
.then(dsRefs => Promise.all(dsRefs.map(ref => ref.deref())))
.then(datasets => {
var match = datasets.filter(dataset => dataset.get('id') === id);
if (match.length > 1) {
throw Error("Um...this can't be good: More than one dataset with id " + id);
}
return match.length == 1 ? match[0].get('heads') : null
});
return match.length === 1 ? match[0].get('head') : null
});
}
function getDatasetIds() {
return store.getRoot()
.then(rootRef => decode.readValue(rootRef, store.getChunk))
.then(root => root.deref())
.then(heads => heads.first().deref())
.then(commit => commit.get('value').deref())
.then(dsRefs => Promise.all(dsRefs.map(ref => ref.deref())))
.then(datasets => datasets.map(dataset => dataset.get('id')))
.then(rootRef => decode.readValue(rootRef, store.getChunk))
.then(root => root.deref())
.then(commit => commit.get('value').deref())
.then(dsRefs => Promise.all(dsRefs.map(ref => ref.deref())))
.then(datasets => datasets.map(dataset => dataset.get('id')))
}
module.exports = {
@@ -38,4 +35,3 @@ module.exports = {
getRef: decode.getRef,
Ref: decode.Ref
};