<commit_before>'use strict';

var express = require('express');
var router = express.Router();
var auth = require('../../auth/auth.service');
var models = require('../../models/index');

// get single panel_settings
router.get('/byPanelType/:id', auth.isAuthenticated(), function(req, res) {
    models.panel_setting.findAll({
        where: {
          panel_type_id: req.params.id
        }
    }).then(function(panel_setting) {
        var settings = [];
        var settingObj = {};
        var values = [];
        var settingTypeSave = 0;
        var settingNameSave = '';
        var i = 0;
        // Panel - Loop
        panel_setting.forEach(function(setting) {
            i++;

            if (settingNameSave === '') {
              // Save Type & Name
              settingTypeSave = setting.setting_type;
              settingNameSave = setting.setting_name;

            } else if(settingNameSave !== setting.setting_name) {
              // Build Object
              settingObj = {};
              settingObj.settingValues = values;
              settingObj.panelTypeID = setting.panel_type_id;
              settingObj.settingType = settingTypeSave;
              settingObj.settingName = settingNameSave;
              settings.push(settingObj);
              // Prepare for next set
              settingTypeSave = setting.setting_type;
              settingNameSave = setting.setting_name;
              values =[];
            }
            var value = {};
            value.panelSettingID = setting.id;
            value.settingValue = setting.setting_value;
            values.push(value);

            // Final Push to settings array
            if (i === panel_setting.length) {
              settingObj = {};
              settingObj.settingValues = values;
              settingObj.panelTypeID = setting.panel_type_id;
              settingObj.settingType = settingTypeSave;
              settingObj.settingName = settingNameSave;
              settings.push(settingObj);
            }
        });

        res.json(settings);
    }).catch(function(err) {
        res.status(401).json(err);
    });
});

module.exports = router;
<commit_msg>panel setting server code cleaning<commit_after>'use strict';

var express = require('express');
var router = express.Router();
var auth = require('../../auth/auth.service');
var models = require('../../models/index');

// get single panel_settings
router.get('/byPanelType/:id', auth.isAuthenticated(), function(req, res) {
    models.panel_setting.findAll({
        where: {
          panel_type_id: req.params.id
        }
    }).then(function(panel_setting) {
        var settings = panel_setting.map(function(setting) {
            var values = [];
            var value = {};
            value.panelSettingID = setting.id;
            value.settingValue = setting.setting_value;
            values.push(value);

            var settingObj = {};
            settingObj.settingValues = values;
            settingObj.panelTypeID = setting.panel_type_id;
            settingObj.settingType = setting.setting_type;
            settingObj.settingName = setting.setting_name;
            return settingObj;
        });

        res.json(settings);
    }).catch(function(err) {
        res.status(401).json(err);
    });
});

module.exports = router;

{'fraction_non_alphanumeric': 0.1213855421686747, 'fraction_numerical': 0.0024096385542168677, 'mean_word_length': 1.9389380530973452, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3819645', 'n_tokens_mistral': 864, 'n_tokens_neox': 852, 'n_words': 166}