1

Adding latitude and longitude into review data

This commit is contained in:
Alex Yatskov 2014-11-17 15:16:05 +09:00
parent b0ed245096
commit 6f5d9ca6bf
2 changed files with 16 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -15,17 +15,19 @@ var conn = mysql.createConnection({
// //
conn.query('DROP TABLE IF EXISTS reviews'); conn.query('DROP TABLE IF EXISTS reviews');
conn.query('CREATE TABLE reviews(name VARCHAR(100) NOT NULL, url VARCHAR(200) NOT NULL, food FLOAT NOT NULL, service FLOAT NOT NULL, value FLOAT NOT NULL, atmosphere FLOAT NOT NULL, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY)'); conn.query('CREATE TABLE reviews(name VARCHAR(100) NOT NULL, url VARCHAR(200) NOT NULL, food FLOAT NOT NULL, service FLOAT NOT NULL, value FLOAT NOT NULL, atmosphere FLOAT NOT NULL, latitude FLOAT NOT NULL, longitude FLOAT NOT NULL, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY)');
for (var i = 0, count = data.length; i < count; ++i) { for (var i = 0, count = data.length; i < count; ++i) {
var record = data[i]; var record = data[i];
conn.query('INSERT INTO reviews(name, url, food, service, value, atmosphere) VALUES(?, ?, ?, ?, ?, ?)', [ conn.query('INSERT INTO reviews(name, url, food, service, value, atmosphere, latitude, longitude) VALUES(?, ?, ?, ?, ?, ?, ?, ?)', [
record.name, record.name,
record.relativeUrl, record.relativeUrl,
record.rating.food, record.rating.food,
record.rating.service, record.rating.service,
record.rating.value, record.rating.value,
record.rating.atmosphere record.rating.atmosphere,
record.geo.latitude,
record.geo.longitude
]); ]);
} }
@ -38,10 +40,10 @@ 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, PRIMARY KEY(name))');
var keywords = { var keywords = {
'delicious': [1.0, 0.0, 0.0, 0.0], delicious: [1.0, 0.0, 0.0, 0.0],
'accommodating': [0.0, 1.0, 0.0, 0.0], accommodating: [0.0, 1.0, 0.0, 0.0],
'well-priced': [0.0, 0.0, 1.0, 0.0], affordable: [0.0, 0.0, 1.0, 0.0],
'atmospheric': [0.0, 0.0, 0.0, 1.0] atmospheric: [0.0, 0.0, 0.0, 1.0]
}; };
for (var keyword in keywords) { for (var keyword in keywords) {