dbrequests is now better : logs error and gets more info
This commit is contained in:
parent
cd10d76d89
commit
3297ddec09
|
@ -1,5 +1,6 @@
|
|||
var pg = require('pg');
|
||||
var pgc = require('../../private.js');
|
||||
var Log = require('../../lib/NodeLog.js');
|
||||
|
||||
var Info = function(id, finishAction) {
|
||||
this.id = id;
|
||||
|
@ -10,7 +11,9 @@ var Info = function(id, finishAction) {
|
|||
arrows: false,
|
||||
resets : false,
|
||||
previousNext: false,
|
||||
hovered: false
|
||||
hovered: false,
|
||||
pointerLocked: false,
|
||||
switchedLockOption: false
|
||||
};
|
||||
|
||||
this.results = {};
|
||||
|
@ -32,6 +35,8 @@ Info.prototype.execute = function() {
|
|||
this.loadResets();
|
||||
this.loadPreviousNext();
|
||||
this.loadHovered();
|
||||
this.loadSwitchedLockOption();
|
||||
this.loadPointerLocked();
|
||||
};
|
||||
|
||||
Info.prototype.tryMerge = function() {
|
||||
|
@ -91,6 +96,9 @@ Info.prototype.loadCameras = function() {
|
|||
"FROM keyboardevent WHERE exp_id = $1 ORDER BY time;",
|
||||
[self.id],
|
||||
function(err, result) {
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in loadCameras');
|
||||
} else {
|
||||
self.results.cameras = [];
|
||||
for (var i in result.rows) {
|
||||
self.results.cameras.push(
|
||||
|
@ -110,6 +118,7 @@ Info.prototype.loadCameras = function() {
|
|||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ready.cameras = true;
|
||||
self.tryMerge();
|
||||
}
|
||||
|
@ -122,6 +131,9 @@ Info.prototype.loadCoins = function() {
|
|||
"SELECT coin_id, time FROM coinclicked WHERE exp_id = $1 ORDER BY time;",
|
||||
[self.id],
|
||||
function(err,result) {
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in loadCoins');
|
||||
} else {
|
||||
self.results.coins = [];
|
||||
for (var i in result.rows) {
|
||||
self.results.coins.push(
|
||||
|
@ -132,6 +144,7 @@ Info.prototype.loadCoins = function() {
|
|||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ready.coins = true;
|
||||
self.tryMerge();
|
||||
}
|
||||
|
@ -144,6 +157,9 @@ Info.prototype.loadArrows = function() {
|
|||
"SELECT arrow_id, time FROM arrowclicked WHERE exp_id = $1 ORDER BY time;",
|
||||
[self.id],
|
||||
function(err, result) {
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in loadArrows');
|
||||
} else {
|
||||
self.results.arrows = [];
|
||||
for (var i in result.rows) {
|
||||
self.results.arrows.push(
|
||||
|
@ -154,6 +170,7 @@ Info.prototype.loadArrows = function() {
|
|||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ready.arrows = true;
|
||||
self.tryMerge();
|
||||
}
|
||||
|
@ -166,6 +183,9 @@ Info.prototype.loadResets = function() {
|
|||
"SELECT time FROM resetclicked WHERE exp_id = $1 ORDER BY time;",
|
||||
[self.id],
|
||||
function(err, result) {
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in loadResets');
|
||||
} else {
|
||||
self.results.resets = [];
|
||||
for (var i in result.rows) {
|
||||
self.results.resets.push(
|
||||
|
@ -175,6 +195,7 @@ Info.prototype.loadResets = function() {
|
|||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ready.resets = true;
|
||||
self.tryMerge();
|
||||
}
|
||||
|
@ -194,6 +215,9 @@ Info.prototype.loadPreviousNext = function () {
|
|||
"FROM previousnextclicked WHERE exp_id = $1 ORDER BY time;",
|
||||
[self.id],
|
||||
function(err, result) {
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in loadPreviousNext');
|
||||
} else {
|
||||
self.results.previousNext = [];
|
||||
for (var i in result.rows) {
|
||||
self.results.previousNext.push(
|
||||
|
@ -214,6 +238,7 @@ Info.prototype.loadPreviousNext = function () {
|
|||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ready.previousNext = true;
|
||||
self.tryMerge();
|
||||
}
|
||||
|
@ -226,6 +251,9 @@ Info.prototype.loadHovered = function() {
|
|||
"SELECT start, time, arrow_id FROM hovered WHERE exp_id = $1 ORDER BY time;",
|
||||
[self.id],
|
||||
function(err, result) {
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in loadHovered');
|
||||
} else {
|
||||
self.results.hovered = [];
|
||||
for (var i in result.rows) {
|
||||
self.results.hovered.push(
|
||||
|
@ -237,12 +265,65 @@ Info.prototype.loadHovered = function() {
|
|||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ready.hovered = true;
|
||||
self.tryMerge();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Info.prototype.loadPointerLocked = function() {
|
||||
var self = this;
|
||||
this.client.query(
|
||||
"SELECT time, locked FROM pointerlocked WHERE exp_id = $1 ORDER BY time;",
|
||||
[self.id],
|
||||
function(err, result) {
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in loadPointerLocked');
|
||||
} else {
|
||||
self.results.pointerlocked = [];
|
||||
for (var i in result.rows) {
|
||||
self.results.pointerlocked.push(
|
||||
{
|
||||
type: "pointerlocked",
|
||||
locked: result.rows[i].locked,
|
||||
time: result.rows[i].time
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ready.pointerLocked = true;
|
||||
self.tryMerge();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Info.prototype.loadSwitchedLockOption = function() {
|
||||
var self = this;
|
||||
this.client.query(
|
||||
"SELECT time, locked FROM switchedlockoption WHERE exp_id = $1 ORDER BY time;",
|
||||
[self.id],
|
||||
function(err, result) {
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in loadSwitchedLockOption');
|
||||
} else {
|
||||
self.results.switchedlockoption = [];
|
||||
for (var i in result.rows) {
|
||||
self.results.switchedlockoption.push(
|
||||
{
|
||||
type: "switchedlockoption",
|
||||
locked: result.rows[i].locked,
|
||||
time: result.rows[i].time
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
self.ready.switchedLockOption = true;
|
||||
self.tryMerge();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var UserCreator = function(finishAction) {
|
||||
this.finishAction = finishAction;
|
||||
|
||||
|
|
Loading…
Reference in New Issue