From 738b97808f16abab0d426d782fe6afc3f80670af Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 17 Nov 2014 16:49:02 +0900 Subject: [PATCH] Adding proximity feature --- client/scripts/grapher.js | 2 +- db/hscd.sql | 5 +++-- scrape/build_db.js | 12 ++++++------ server/search.js | 11 +++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/scripts/grapher.js b/client/scripts/grapher.js index f9a9c9a..8603923 100644 --- a/client/scripts/grapher.js +++ b/client/scripts/grapher.js @@ -88,7 +88,7 @@ var _padding = 10; var _panelSize = 20; var _tickSize = 5; - var _width = 125; + var _width = 110; var _easeTime = 400; var _animation = null; diff --git a/db/hscd.sql b/db/hscd.sql index f7a9c02..ce999b2 100644 --- a/db/hscd.sql +++ b/db/hscd.sql @@ -28,6 +28,7 @@ CREATE TABLE `keywords` ( `service` float NOT NULL, `value` float NOT NULL, `atmosphere` float NOT NULL, + `proximity` float NOT NULL, PRIMARY KEY (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38,7 +39,7 @@ CREATE TABLE `keywords` ( LOCK TABLES `keywords` WRITE; /*!40000 ALTER TABLE `keywords` DISABLE KEYS */; -INSERT INTO `keywords` VALUES ('accommodating',0,1,0,0),('affordable',0,0,1,0),('atmospheric',0,0,0,1),('delicious',1,0,0,0); +INSERT INTO `keywords` VALUES ('accommodating',0,1,0,0,0),('affordable',0,0,1,0,0),('atmospheric',0,0,0,1,0),('delicious',1,0,0,0,0); /*!40000 ALTER TABLE `keywords` ENABLE KEYS */; UNLOCK TABLES; @@ -105,4 +106,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2014-11-17 15:15:16 +-- Dump completed on 2014-11-17 16:48:17 diff --git a/scrape/build_db.js b/scrape/build_db.js index 600979a..429ce98 100755 --- a/scrape/build_db.js +++ b/scrape/build_db.js @@ -37,18 +37,18 @@ for (var i = 0, count = data.length; i < count; ++i) { // conn.query('DROP TABLE IF EXISTS keywords'); -conn.query('CREATE TABLE keywords(name VARCHAR(50) NOT NULL, food FLOAT NOT NULL, service FLOAT NOT NULL, value FLOAT NOT NULL, atmosphere FLOAT NOT NULL, PRIMARY KEY(name))'); +conn.query('CREATE TABLE keywords(name VARCHAR(50) NOT NULL, food FLOAT NOT NULL, service FLOAT NOT NULL, value FLOAT NOT NULL, atmosphere FLOAT NOT NULL, proximity FLOAT NOT NULL, PRIMARY KEY(name))'); var keywords = { - delicious: [1.0, 0.0, 0.0, 0.0], - accommodating: [0.0, 1.0, 0.0, 0.0], - affordable: [0.0, 0.0, 1.0, 0.0], - atmospheric: [0.0, 0.0, 0.0, 1.0] + delicious: [1.0, 0.0, 0.0, 0.0, 0.0], + accommodating: [0.0, 1.0, 0.0, 0.0, 0.0], + affordable: [0.0, 0.0, 1.0, 0.0, 0.0], + atmospheric: [0.0, 0.0, 0.0, 1.0, 0.0] }; for (var keyword in keywords) { var record = keywords[keyword]; - conn.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?)', [keyword].concat(record)); + conn.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?, ?)', [keyword].concat(record)); } diff --git a/server/search.js b/server/search.js index a411415..cbf960e 100644 --- a/server/search.js +++ b/server/search.js @@ -152,7 +152,8 @@ function addKeyword(query, callback) { query.features.food, query.features.service, query.features.value, - query.features.atmosphere + query.features.atmosphere, + query.features.proximity ]; pool.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?)', values, function(err) { @@ -183,7 +184,8 @@ function getKeywords(callback) { food: row.food, service: row.service, value: row.value, - atmosphere: row.atmosphere + atmosphere: row.atmosphere, + proximity: row.proximity }; } @@ -232,10 +234,7 @@ function getData(callback) { function getParameters(callback) { getKeywords(function(keywords) { - callback({ - keywords: keywords, - features: [ 'food', 'service', 'atmosphere', 'value' ] - }); + callback({ keywords: keywords }); }); }