From ae82f57c67a0a85bfed0de3a7acb4285247b37dd Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Thu, 28 Nov 2013 15:55:40 -0500 Subject: [PATCH 1/4] added upgrade script to delete removed keys from posts --- src/upgrade.js | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/upgrade.js b/src/upgrade.js index cec799914d..0780f1a0f7 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -11,7 +11,7 @@ var RDB = require('./redis.js'), Upgrade.check = function(callback) { // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema - var latestSchema = new Date(2013, 10, 26).getTime(); + var latestSchema = new Date(2013, 10, 28).getTime(); RDB.get('schemaDate', function(err, value) { if (parseInt(value, 10) >= latestSchema) { @@ -179,7 +179,7 @@ Upgrade.upgrade = function(callback) { }, function(next) { thisSchemaDate = new Date(2013, 10, 26).getTime(); - if (schemaDate < thisSchemaDate || 1) { + if (schemaDate < thisSchemaDate) { categories.getAllCategories(0, function(err, categories) { function updateIcon(category, next) { @@ -209,6 +209,41 @@ Upgrade.upgrade = function(callback) { winston.info('[2013/11/26] Update to Category icons skipped.'); next(); } + }, + function(next) { + thisSchemaDate = new Date(2013, 10, 28).getTime(); + if (schemaDate < thisSchemaDate) { + var keysToDelete = [ + 'fav_button_class', + 'fav_star_class', + 'show_banned', + 'relativeTime', + 'post_rep', + 'edited-class', + 'relativeEditTime' + ]; + + RDB.keys('post:*', function(err, posts) { + if(err) { + return next(err); + } + + function deleteRemovedData(key, callback) { + RDB.hdel(key, keysToDelete, callback) + } + + async.each(posts, deleteRemovedData, function(err) { + if(err) { + return next(err); + } + winston.info('[2013/11/28] Deleted removed post data.'); + next(err); + }); + }); + } else { + winston.info('[2013/11/26] Update to Post data skipped.'); + next(); + } } // Add new schema updates here // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 12!!! From 4335f8c5c6c99eb773dd856f11c171391390aa0f Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Thu, 28 Nov 2013 15:57:00 -0500 Subject: [PATCH 2/4] fixed date in upgrade --- src/upgrade.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/upgrade.js b/src/upgrade.js index 0780f1a0f7..b74dac23b5 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -241,7 +241,7 @@ Upgrade.upgrade = function(callback) { }); }); } else { - winston.info('[2013/11/26] Update to Post data skipped.'); + winston.info('[2013/11/28] Update to Post data skipped.'); next(); } } From f2bf65252d411a779d05958ca99c85c856f2f7f3 Mon Sep 17 00:00:00 2001 From: Baris Usakli Date: Thu, 28 Nov 2013 16:15:18 -0500 Subject: [PATCH 3/4] removed the fields --- public/src/templates.js | 18 +++++++++--------- public/templates/topic.tpl | 2 +- src/posts.js | 8 -------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/public/src/templates.js b/public/src/templates.js index d933a7db74..7815568d5a 100644 --- a/public/src/templates.js +++ b/public/src/templates.js @@ -312,20 +312,20 @@ function checkConditional(key, value) { var conditional = makeConditionalRegex(key), conditionalBlock = conditional.exec(template); - + if (conditionalBlock !== null) { conditionalBlock = conditionalBlock[0].split(//); - + if (conditionalBlock[1]) { // there is an else statement if (!value) { - template = template.replace(conditional, conditionalBlock[1]); + template = template.replace(conditional, conditionalBlock[1]); } else { - template = template.replace(conditional, conditionalBlock[0]); + template = template.replace(conditional, conditionalBlock[0]); } - + } else { - // regular if + // regular if if (!value) { template = template.replace(conditional, ''); } @@ -335,13 +335,13 @@ checkConditional(namespace + d, data[d]); checkConditional('!' + namespace + d, !data[d]); - + if (blockInfo) { checkConditional('@first', blockInfo.iterator === 0); checkConditional('@last', blockInfo.iterator === blockInfo.total); } - - + + template = replace(namespace + d, data[d], template); } } diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index d4e0c41bb8..ae9b3110b3 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -66,7 +66,7 @@
- -