From d4e7db45b781ac65b7550d3ca8f3047e231e7fee Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Mon, 29 May 2017 11:23:25 -0600
Subject: [PATCH] Use zipObject, more test-related ignores
---
.gitignore | 1 +
src/privileges/categories.js | 4 +---
src/privileges/topics.js | 4 +---
src/topics.js | 8 ++------
src/topics/tags.js | 4 +---
5 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/.gitignore b/.gitignore
index 9f6eedfe2e..028f91e53b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,3 +61,4 @@ coverage
build
*.log
test/files/normalise.jpg.png
+test/files/normalise-resized.jpg
diff --git a/src/privileges/categories.js b/src/privileges/categories.js
index 73d0ebc220..49bdb29311 100644
--- a/src/privileges/categories.js
+++ b/src/privileges/categories.js
@@ -171,9 +171,7 @@ module.exports = function (privileges) {
}, next);
},
function (results, next) {
- var privData = _.fromPairs(privs.map(function (priv, i) {
- return [priv, results.privileges[i]];
- }));
+ var privData = _.zipObject(privs, results.privileges);
var isAdminOrMod = results.isAdministrator || results.isModerator;
plugins.fireHook('filter:privileges.categories.get', {
diff --git a/src/privileges/topics.js b/src/privileges/topics.js
index bf02b11797..88273800fe 100644
--- a/src/privileges/topics.js
+++ b/src/privileges/topics.js
@@ -29,9 +29,7 @@ module.exports = function (privileges) {
}, next);
},
function (results, next) {
- var privData = _.fromPairs(privs.map(function (priv, i) {
- return [priv, results.privileges[i]];
- }));
+ var privData = _.zipObject(privs, results.privileges);
var disabled = parseInt(results.disabled, 10) === 1;
var locked = parseInt(topic.locked, 10) === 1;
var deleted = parseInt(topic.deleted, 10) === 1;
diff --git a/src/topics.js b/src/topics.js
index 6869912abc..575199d400 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -135,12 +135,8 @@ Topics.getTopicsByTids = function (tids, uid, callback) {
}, next);
},
function (results, next) {
- var users = _.fromPairs(results.users.map(function (user) {
- return [user.uid, user];
- }));
- var categories = _.fromPairs(results.categories.map(function (category) {
- return [category.cid, category];
- }));
+ var users = _.zipObject(uids, results.users);
+ var categories = _.zipObject(cids, results.categories);
for (var i = 0; i < topics.length; i += 1) {
if (topics[i]) {
diff --git a/src/topics/tags.js b/src/topics/tags.js
index d6bf35a6e0..dbfb092cc1 100644
--- a/src/topics/tags.js
+++ b/src/topics/tags.js
@@ -247,9 +247,7 @@ module.exports = function (Topics) {
tag.score = results.counts[index] ? results.counts[index] : 0;
});
- var tagData = _.fromPairs(results.tagData.map(function (tag) {
- return [tag.value, tag];
- }));
+ var tagData = _.zipObject(uniqueTopicTags, results.tagData);
topicTags.forEach(function (tags, index) {
if (Array.isArray(tags)) {