From 5f5914ee5c5cad7dff0b9f5a326180e91c695200 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Thu, 17 May 2018 20:56:13 -0300 Subject: [PATCH] Regression: Fix wrong wizard field name (#10804) --- .../server/functions/get.js | 54 +++++++------------ 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/packages/rocketchat-statistics/server/functions/get.js b/packages/rocketchat-statistics/server/functions/get.js index 226119a71511..0d3e28e4e22c 100644 --- a/packages/rocketchat-statistics/server/functions/get.js +++ b/packages/rocketchat-statistics/server/functions/get.js @@ -2,46 +2,30 @@ import _ from 'underscore'; import os from 'os'; +const wizardFields = [ + 'Organization_Type', + 'Organization_Name', + 'Industry', + 'Size', + 'Country', + 'Website', + 'Site_Name', + 'Language', + 'Server_Type' +]; + RocketChat.statistics.get = function _getStatistics() { const statistics = {}; // Setup Wizard statistics.wizard = {}; - if (RocketChat.models.Settings.findOne('Organization_Type')) { - statistics.wizard.organizationType = RocketChat.models.Settings.findOne('Organization_Type').value; - } - - if (RocketChat.models.Settings.findOne('Organization_Name')) { - statistics.wizard.organizationName = RocketChat.models.Settings.findOne('Organization_Name').value; - } - - if (RocketChat.models.Settings.findOne('Industry')) { - statistics.wizard.industry = RocketChat.models.Settings.findOne('Industry').value; - } - - if (RocketChat.models.Settings.findOne('Size')) { - statistics.wizard.size = RocketChat.models.Settings.findOne('Size').value; - } - - if (RocketChat.models.Settings.findOne('Country')) { - statistics.wizard.country = RocketChat.models.Settings.findOne('Country').value; - } - - if (RocketChat.models.Settings.findOne('Website')) { - statistics.wizard.website = RocketChat.models.Settings.findOne('Website').value; - } - - if (RocketChat.models.Settings.findOne('Site_Name')) { - statistics.wizard.siteName = RocketChat.models.Settings.findOne('Site_Name').value; - } - - if (RocketChat.models.Settings.findOne('Language')) { - statistics.wizard.siteName = RocketChat.models.Settings.findOne('Site_Name').value; - } - - if (RocketChat.models.Settings.findOne('Server_Type')) { - statistics.wizard.serverType = RocketChat.models.Settings.findOne('Server_Type').value; - } + wizardFields.forEach(field => { + const record = RocketChat.models.Settings.findOne(field); + if (record) { + const wizardField = field.replace(/_/g, '').replace(field[0], field[0].toLowerCase()); + statistics.wizard[wizardField] = record.value; + } + }); // Version statistics.uniqueId = RocketChat.settings.get('uniqueID');