Log review accesses
This commit is contained in:
parent
e4815b407b
commit
65bba56252
@ -43,7 +43,7 @@
|
||||
$('#profileDlg').on('hidden.bs.modal', onSearch);
|
||||
|
||||
window.accessReview = function(id) {
|
||||
$.getJSON('/access', {id: id}, function(results) {
|
||||
$.getJSON('/access', {id: id, profile: localStorage}, function(results) {
|
||||
if (results.success) {
|
||||
location.replace(results.url);
|
||||
}
|
||||
|
@ -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('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)');
|
||||
|
||||
|
||||
//
|
||||
|
@ -260,6 +260,19 @@ function accessReview(query, callback) {
|
||||
|
||||
if (results.success) {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user