Corrected bad bug
This commit is contained in:
parent
3d007e8877
commit
0c8338895a
|
@ -855,6 +855,14 @@ DBReq.ExpCreator.prototype.execute = function() {
|
|||
DBReq.ExpCreator.prototype.finish = function() {
|
||||
var self = this;
|
||||
|
||||
// self.finishAction(
|
||||
// self.finalResult.expId,
|
||||
// self.finalResult.coinCombinationId,
|
||||
// self.finalResult.sceneId,
|
||||
// self.finalResult.recommendationStyle,
|
||||
// self.finalResult.coins
|
||||
// );
|
||||
|
||||
// Commit, and then release
|
||||
this.client.query("COMMIT;", function() {
|
||||
|
||||
|
@ -1046,10 +1054,12 @@ DBReq.LastExpGetter.prototype.execute = function() {
|
|||
'FROM Experiment, CoinCombination \n' +
|
||||
'WHERE Experiment.coin_combination_id = CoinCombination.id \n' +
|
||||
' AND Experiment.user_id = $1 \n' +
|
||||
' AND NOT Experiment.finished \n' +
|
||||
'ORDER BY Experiment.id DESC \n' +
|
||||
'LIMIT 1;',
|
||||
[self.userId],
|
||||
function (err, result) {
|
||||
|
||||
if (err !== null) {
|
||||
Log.dberror(err + ' in LastExpGetter (DBReq)');
|
||||
}
|
||||
|
@ -1059,21 +1069,29 @@ DBReq.LastExpGetter.prototype.execute = function() {
|
|||
}, 1000);
|
||||
return;
|
||||
}
|
||||
self.finalResult.sceneId = result.rows[0].sceneId;
|
||||
self.finalResult.recommendationStyle = result.rows[0].recommendationStyle;
|
||||
self.finalResult.coins = [
|
||||
result.rows[0].coin_1,
|
||||
result.rows[0].coin_2,
|
||||
result.rows[0].coin_3,
|
||||
result.rows[0].coin_4,
|
||||
result.rows[0].coin_5,
|
||||
result.rows[0].coin_6,
|
||||
result.rows[0].coin_7,
|
||||
result.rows[0].coin_8
|
||||
];
|
||||
self.finalResult.coinCombinationId = result.rows[0].coinCombinationId;
|
||||
self.finalResult.expId = result.rows[0].expId;
|
||||
self.finish();
|
||||
|
||||
self.client.query(
|
||||
'UPDATE Experiment SET finished = true WHERE id = $1',
|
||||
[result.rows[0].expId],
|
||||
function() {
|
||||
self.finalResult.sceneId = result.rows[0].sceneId;
|
||||
self.finalResult.recommendationStyle = result.rows[0].recommendationStyle;
|
||||
self.finalResult.coins = [
|
||||
result.rows[0].coin_1,
|
||||
result.rows[0].coin_2,
|
||||
result.rows[0].coin_3,
|
||||
result.rows[0].coin_4,
|
||||
result.rows[0].coin_5,
|
||||
result.rows[0].coin_6,
|
||||
result.rows[0].coin_7,
|
||||
result.rows[0].coin_8
|
||||
];
|
||||
self.finalResult.coinCombinationId = result.rows[0].coinCombinationId;
|
||||
self.finalResult.expId = result.rows[0].expId;
|
||||
self.finish();
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -1192,8 +1210,8 @@ DBReq.TutorialCreator.prototype.execute = function() {
|
|||
function(err, result) {
|
||||
// Create experiment
|
||||
self.client.query(
|
||||
"INSERT INTO Experiment(user_id, coin_combination_id)\n" +
|
||||
"VALUES($1,$2)\n" +
|
||||
"INSERT INTO Experiment(user_id, coin_combination_id, finished)\n" +
|
||||
"VALUES($1,$2, true)\n" +
|
||||
"RETURNING id;",
|
||||
[self.id, result.rows[0].id],
|
||||
function(err, result) {
|
||||
|
|
|
@ -81,10 +81,26 @@ module.exports.play = function(req, res) {
|
|||
|
||||
db.getLastExp(req.session.userId, function(expId, sceneId, coinId, recoStyle, coins) {
|
||||
|
||||
// if (coinId === undefined) {
|
||||
// console.log("=== ERROR : COIN_ID IS UNDEFINED ===");
|
||||
// process.exit(-1)
|
||||
// }
|
||||
|
||||
res.locals.scene = sceneToFunction(sceneId);
|
||||
res.locals.recommendationStyle = recoStyle;
|
||||
res.locals.coins = coins;
|
||||
|
||||
// var elt = req.session.experiments.find(function(elt) {
|
||||
// return elt.coinCombinationId === coinId;
|
||||
// });
|
||||
|
||||
// if (elt !== undefined) {
|
||||
// console.log("=== ERROR DETECTED === user " + req.session.userId);
|
||||
// console.log(req.session.experiments);
|
||||
// console.log(coinId);
|
||||
// process.exit(-1)
|
||||
// }
|
||||
|
||||
req.session.experiments.push({
|
||||
sceneId: sceneId,
|
||||
recommendationStyle: recoStyle,
|
||||
|
|
|
@ -73,7 +73,8 @@ CREATE TABLE Experiment(
|
|||
id SERIAL PRIMARY KEY,
|
||||
user_id SERIAL REFERENCES Users (id),
|
||||
coin_combination_id SERIAL REFERENCES CoinCombination (id),
|
||||
recommendation_style VARCHAR(30)
|
||||
recommendation_style VARCHAR(30),
|
||||
finished BOOLEAN DEFAULT(false)
|
||||
);
|
||||
|
||||
-- Init scene table
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var baseUrl = 'http://localhost:4000/';
|
||||
var baseUrl = 'http://3dinterface.no-ip.org/';
|
||||
// var baseUrl = 'http://3dinterface.no-ip.org/';
|
||||
|
||||
function makeId()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue