From 3318ac364d8587964b33d744ce74492c11a0101e Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Sat, 24 Oct 2020 00:29:42 -0400 Subject: [PATCH] Code cleanup and changed proposed handling of existing tags for suggestions --- backend/categories.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/backend/categories.js b/backend/categories.js index d7df916..d0b249a 100644 --- a/backend/categories.js +++ b/backend/categories.js @@ -102,27 +102,21 @@ function applyCategoryRules(file_json, rules, category_name) { } async function addTagToVideo(tag, video, user_uid) { - + // TODO: Implement } async function removeTagFromVideo(tag, video, user_uid) { - + // TODO: Implement } -async function incrementTagCount(tag) { - const current_value = db.get(`stats.tags.${tag}`).value(); - if (!current_value) { - db.set(`stats.tags.${tag}`, 1).write(); - } else { - db.update(`stats.tags.${tag}`, n => n + 1).write(); +// adds tag to list of existing tags (used for tag suggestions) +async function addTagToExistingTags(tag) { + const existing_tags = db.get('tags').value(); + if (!existing_tags.includes(tag)) { + db.get('tags').push(tag).write(); } } -async function decrementTagCount(tag) { - db.update(`stats.tags.${tag}`, n => n - 1).write(); -} - - module.exports = { initialize: initialize, categorize: categorize,