1

Log review accesses

This commit is contained in:
Alex Yatskov 2015-03-11 15:50:00 +09:00
parent e4815b407b
commit 65bba56252
3 changed files with 15 additions and 2 deletions

View File

@ -43,7 +43,7 @@
$('#profileDlg').on('hidden.bs.modal', onSearch); $('#profileDlg').on('hidden.bs.modal', onSearch);
window.accessReview = function(id) { window.accessReview = function(id) {
$.getJSON('/access', {id: id}, function(results) { $.getJSON('/access', {id: id, profile: localStorage}, function(results) {
if (results.success) { if (results.success) {
location.replace(results.url); location.replace(results.url);
} }

View File

@ -90,7 +90,7 @@ conn.query('CREATE TABLE history(date DATETIME NOT NULL, reviewId INT NOT NULL,
// //
conn.query('DROP TABLE IF EXISTS historyGroups'); conn.query('DROP TABLE IF EXISTS historyGroups');
conn.query('CREATE TABLE historyGroups(categoryId INT NOT NULL, historyId INT NOT NULL)'); conn.query('CREATE TABLE historyGroups(categoryId INT NOT NULL, categoryValue FLOAT NOT NULL, historyId INT NOT NULL)');
// //

View File

@ -260,6 +260,19 @@ function accessReview(query, callback) {
if (results.success) { if (results.success) {
results.url = 'http://www.tripadvisor.com' + rows[0].url; results.url = 'http://www.tripadvisor.com' + rows[0].url;
pool.query('INSERT INTO history(date, reviewId) VALUES(NOW(), ?)', [query.id], function(err, info) {
if (err) {
throw err;
}
for (var categoryId in query.profile) {
pool.query(
'INSERT INTO historyGroups(categoryId, categoryValue, historyId) VALUES(?, ?, ?)',
[categoryId, query.profile[categoryId], info.insertId]
);
}
});
} }
callback(results); callback(results);