Large diffs are not rendered by default.

@@ -1,4 +1,5 @@
require('mapbox.js')
r = require('rethinkdb');

console.log(process.env.IAIN_MAPBOX_ACCESS_TOKEN);

@@ -11,7 +12,6 @@ map.setView([-41.112, 172.694], 6)

var pointDataLayer = L.mapbox.featureLayer().addTo(map)


var sampleGeoJson = {
"type": "FeatureCollection",
"features": [
@@ -68,4 +68,4 @@ var geoJson = L.geoJson(sampleGeoJson, {
radius: 5
})
}
}).addTo(map)
}).addTo(map)
@@ -1,22 +1,45 @@
var express = require('express');
var r = require('rethinkdb');
var app = express();

// set the port of our application
// process.env.PORT lets the port be set by Heroku
var port = process.env.PORT || 8080;
var port = process.env.PORT || 8000;

// set the view engine to ejs
app.set('view engine', 'ejs');
// Load config for app
var config = require(__dirname+"/config.js");

// make express look in the public directory for assets (css/js/img)
app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname+'/public'));

// set the home page route
app.get('/', function(req, res) {
// ejs render automatically looks in the views folder
res.render('index');
res.sendfile('index.html');
});

app.get('/datasets/nzfapdc', function(req, res) {
var connection = null;
r.connect(config.rethinkdb).then(function(conn) {
connection = conn;
return r.table('nzfapdc').limit(20).run(connection)
}).then(function(cursor) {
return cursor.toArray();
}).then(function(result) {
res.send(JSON.stringify(result));
}).error(handleError(res))
.finally(function(){connection.close()});
});

app.listen(port, function() {
console.log('Our app is running on http://localhost:' + port);
});

/*
* Send back a 500 error
*/
function handleError(res) {
return function(error) {
res.send(500, {error: error.message});
}
}
@@ -0,0 +1,26 @@
r = require('rethinkdb');

var connection = null;
r.connect({host: 'localhost', port: 28015}, function(err, conn) {
if (err) throw err;
connection = conn;
populateTable();
});

var populateTable = function() {
var query = r.db('test').table('nzfapdc').group("Matched Scientific Name").count().ungroup().orderBy(r.desc('reduction'));

r.db('test').tableDrop('nzfapdcDropdown').run(connection).then(function(){
return r.db('test').tableCreate('nzfapdcDropdown').run(connection)
}).then(function(){
return query.run(connection);
}).then(function(cursor){
return cursor.toArray()
}).then(function(results){
return r.db('test').table('nzfapdcDropdown').insert(results).run(connection);
}).error(function(err) {
if (err) throw err;
}).finally(function(){
connection.close();
});
};