Skip to content

Commit

Permalink
Clean linting errors, add indices.
Browse files Browse the repository at this point in the history
  • Loading branch information
crertel committed Jul 11, 2016
1 parent af9d0bc commit 0e5b957
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
10 changes: 10 additions & 0 deletions database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ CREATE TABLE results (
agent TEXT NOT NULL, -- the user agent of the user performing the task
robot_count INTEGER NOT NULL DEFAULT 0 -- the number of roboots involved in the task.
);

DROP INDEX IF EXISTS results_tasks_idx;
CREATE INDEX results_tasks_idx ON results(task);

DROP INDEX IF EXISTS results_tasks_with_mode_idx;
CREATE INDEX results_tasks_with_mode_idx ON results(task,mode);

DROP INDEX IF EXISTS results_participant_idx;
CREATE INDEX results_participant_idx ON results(participant);

15 changes: 10 additions & 5 deletions server/resultController.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';


function URFP( x ) { /* jshint expr:true */ x; }
var express = require('express');
var router = express.Router();
Expand All @@ -13,8 +15,9 @@ router.get('/', function _renderResultsIndex( req, res ) {
.then( function( results ) {
// fix date to be formatted usefully
results = results.map( function _fixupDates( r ){
r["created_at"] = r["created_at"].toISOString();
r["updated_at"] = r["updated_at"].toISOString();
/* jshint sub:true */
r['created_at'] = r['created_at'].toISOString();
r['updated_at'] = r['updated_at'].toISOString();
return r;
});

Expand Down Expand Up @@ -52,8 +55,9 @@ router.get('/:resultID', function _renderResultsIndex( req, res ) {
.then( function( results ) {
// fix date to be formatted usefully
results = results.map( function _fixupDates( r ){
r["created_at"] = r["created_at"].toISOString();
r["updated_at"] = r["updated_at"].toISOString();
/* jshint sub:true */
r['created_at'] = r['created_at'].toISOString();
r['updated_at'] = r['updated_at'].toISOString();
return r;
});

Expand Down Expand Up @@ -87,11 +91,12 @@ router.get('/:resultID', function _renderResultsIndex( req, res ) {
});

router.post('/', function _renderResultsIndex( req, res ) {
/* jshint sub:true */
try{
console.log('\n---\n', JSON.stringify(req.body), '\n---\n');
var info = {
task: req.body.task,
participant: req.cookies['task_sig'] || "unknown",
participant: req.cookies['task_sig'] || 'unknown',
runtime: req.body.runtime,
mode: req.body.mode,
agent: req.body.agent || req.header('user-agent'),
Expand Down
1 change: 1 addition & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var kTwentyYears = 1000 * 60 * 60 * 24 * 365 * 20;
app.use( cookieParser() );
app.use( bodyParser.json() );
app.use( function _addTaskSig( req, res, next ) {
/* jshint sub:true */
if (!req.cookies['task_sig']) {
res.cookie( 'task_sig',
crypto.randomBytes(16).toString('hex'),
Expand Down
7 changes: 7 additions & 0 deletions test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"task" : "test task",
"mode" : "test mode",
"numrobots" : 32,
"runtime": 43.23,
"aborted": true
}

0 comments on commit 0e5b957

Please sign in to comment.