Added users to games in sample data

main
Umbra Sheep 7 years ago
parent 294b3ff7d3
commit e0377fc548

@ -9,7 +9,7 @@ exports.connect = function(done){
state.pool = mysql.createPool({ state.pool = mysql.createPool({
host: 'localhost', host: 'localhost',
user: 'root', user: 'root',
password: '', password: 'root',
port: 3306, port: 3306,
database: "territory-walker", database: "territory-walker",
//multipleStatements: true //multipleStatements: true

@ -63,13 +63,17 @@ BEGIN
DECLARE lastid VARCHAR(36) DEFAULT UUID(); DECLARE lastid VARCHAR(36) DEFAULT UUID();
INSERT INTO `polygonArea` (gameID, polygonID, userID, area) VALUES INSERT INTO `polygonArea` (gameID, polygonID, userID, area) VALUES
(gID, lastid, usID, a); (gID, lastid, usID, a);
SELECT * FROM `polygonArea` WHERE polygonID = lastid; SELECT * FROM `polygonArea`
JOIN userJoinedGames ON
userJoinedGames.userID = polygonArea.userID AND userJoinedGames.gameID = polygonArea.gameID
WHERE polygonID = lastid;
END // END //
DELIMITER ; DELIMITER ;
INSERT INTO `gameInstances` (gameID) VALUES ("samdum"); INSERT INTO `gameInstances` (gameID) VALUES ("samdum");
INSERT INTO `users` (userID, nickname) VALUES ("samded", "Lesmaux"); INSERT INTO `users` (userID, nickname) VALUES ("samded", "Lesmaux");
INSERT INTO `users` (userID, nickname) VALUES ("fanded", "Umbra Sheep"); INSERT INTO `users` (userID, nickname) VALUES ("fanded", "Umbra Sheep");
INSERT INTO `userJoinedGames` (userID, gameID, colour) VALUES ("samded", "samdum", "0000FF");
INSERT INTO `polygonArea` (gameID, polygonID, userID, area) VALUES INSERT INTO `polygonArea` (gameID, polygonID, userID, area) VALUES
("samdum", "someuniqueid", "samded", 100000.1); ("samdum", "someuniqueid", "samded", 100000.1);
INSERT INTO `polygonPoints` (polygonID, lat, lng) VALUES INSERT INTO `polygonPoints` (polygonID, lat, lng) VALUES

@ -7,7 +7,11 @@ module.exports = {
if (req.query.gameID != null) { if (req.query.gameID != null) {
let query = "CALL getPolygonPoints(\"" + req.query.gameID + "\");"; let query = "CALL getPolygonPoints(\"" + req.query.gameID + "\");";
db.get().query(query, function(err, rows){ db.get().query(query, function(err, rows){
if (err) return res.send(400); if (err) {
console.log(err);
return res.send(400);
}
// console.log(rows);
res.send(rows[0]); res.send(rows[0]);
return; return;
}); });
@ -20,7 +24,6 @@ module.exports = {
let gameID = req.body.gameID; let gameID = req.body.gameID;
let userID = req.body.userID; let userID = req.body.userID;
let points = JSON.parse(req.body.points); let points = JSON.parse(req.body.points);
console.log(points);
if (points.length < 2) { if (points.length < 2) {
res.send([]); res.send([]);
} else { } else {

Loading…
Cancel
Save