Adding preset table to prevent core keywords from being deleted
This commit is contained in:
parent
764643da03
commit
bb4a2ab896
@ -152,6 +152,7 @@
|
||||
|
||||
$('#forgetKeyword').click(onForget);
|
||||
$('#forgetDialog').on('show.bs.modal', function() {
|
||||
$('#forgetError').hide();
|
||||
$.getJSON('/node/getKeywords', function(keywords) {
|
||||
$('#forgetKeyword').prop('disabled', keywords.length === 0);
|
||||
$('#keywordToForget').empty();
|
||||
|
12
scrape/db.js
12
scrape/db.js
@ -49,4 +49,16 @@ for (var keyword in keywords) {
|
||||
conn.query('INSERT INTO keywords VALUES(?, ?, ?, ?, ?)', [keyword].concat(record));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Presets
|
||||
//
|
||||
|
||||
conn.query('DROP TABLE IF EXISTS presets');
|
||||
conn.query('CREATE TABLE presets(name VARCHAR(50) NOT NULL, PRIMARY KEY(name))');
|
||||
|
||||
for (var keyword in keywords) {
|
||||
conn.query('INSERT INTO presets VALUES(?)', [keyword]);
|
||||
}
|
||||
|
||||
conn.end();
|
||||
|
@ -42,6 +42,29 @@ INSERT INTO `keywords` VALUES ('atmosphere',0,0,0,1),('food',1,0,0,0),('service'
|
||||
/*!40000 ALTER TABLE `keywords` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `presets`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `presets`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `presets` (
|
||||
`name` varchar(50) NOT NULL,
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `presets`
|
||||
--
|
||||
|
||||
LOCK TABLES `presets` WRITE;
|
||||
/*!40000 ALTER TABLE `presets` DISABLE KEYS */;
|
||||
INSERT INTO `presets` VALUES ('atmosphere'),('food'),('service'),('value');
|
||||
/*!40000 ALTER TABLE `presets` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `reviews`
|
||||
--
|
||||
@ -78,4 +101,4 @@ UNLOCK TABLES;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2014-09-19 10:22:03
|
||||
-- Dump completed on 2014-09-20 18:31:08
|
||||
|
@ -168,10 +168,10 @@ function addKeyword(query, callback) {
|
||||
}
|
||||
|
||||
function removeKeyword(query, callback) {
|
||||
connection.query('DELETE FROM keywords WHERE name=?', [query.keyword], function(err) {
|
||||
connection.query('DELETE FROM keywords WHERE name=? AND name NOT IN (SELECT name FROM presets)', [query.keyword], function(err, fields) {
|
||||
callback({
|
||||
keyword: query.keyword,
|
||||
success: err === null
|
||||
success: err === null && fields.affectedRows > 0
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user