<commit_before>    'use strict';

/**
 * Module dependencies.
 */
var mongoose = require('mongoose'),
    _ = require('lodash'),
    request = require('request'),
    soap = require('soap'),
    fs = require('fs'),
    async = require('async'),
    Walkin = mongoose.model('Walkin'),
    Checkin = mongoose.model('Checkin'),
    ContactLog = mongoose.model('ContactLog');

// Get credentials (& reformat wsdl url)
var credentialFilePath = __dirname + '/../../credentials/ServiceNow.json',
    credentialFile = fs.readFileSync(credentialFilePath, 'utf8'),
    credential = JSON.parse(credentialFile);

if(credential.username){
    var index = credential.wsdl_url.indexOf('//') + '//'.length;
    credential.wsdl_url = credential.wsdl_url.substring(0, index) + credential.username + ':' + credential.password + '@' + credential.wsdl_url.substring(index);
}

var popOpt_walkin = [
    { path : 'user', model : 'User', select : 'username'},
    { path : 'lastUpdateTechnician', model : 'User', select : 'username'},
    { path : 'serviceTechnician', model : 'User', select : 'username'},
    { path : 'resoluteTechnician', model : 'User', select : 'username'}
];

var popOpt_checkin = [
    { path : 'user', model : 'User', select : 'firstName lastName displayName username phone location verified'},
    { path : 'walkin', model : 'Walkin', select : 'description resoluteTechnician deviceCategory deviceType os otherDevice'},
    { path : 'serviceLog', model : 'ServiceEntry', select : 'type description createdBy createdAt'},
    { path : 'completionTechnician', model : 'User', select : 'username displayName'},
    { path : 'verificationTechnician', model : 'User', select : 'username displayName'},
    { path : 'checkoutTechnician', model : 'User', select : 'username displayName'},
    { path : 'contactLog', model : 'ContactLog'}
];

var popOpt_checkin_walkin = [{ path : 'walkin.resoluteTechnician',  model : 'User', select : 'username displayName'}];

var getWalkinTemplateObj = function(walkin){
    var subject = 'STS: ', os = walkin.os;
    var obj = { short_description: '', category1 : '', category2 : '', category3 : '' };

    switch(walkin.resolutionType){
        case 'DooleyNet':
            subject += 'DN ' + walkin.deviceType;
            if(walkin.deviceType === 'Other') subject += ' ' + walkin.otherDevice;

            obj.type = 'Service Request';
            obj.category1 = 'Application Management';
            obj.category2 = 'Access';
            obj.category3 = 'Inaccessible';
            break;

        case 'EmoryUnplugged':
            subject += 'EU ';
            if(os === 'N/A') os = walkin.otherDevice;
            else if(os.indexOf('(') >= 0) os = os.substring(0, os.indexOf('(')).trim();

            switch(walkin.deviceCategory){
                case 'Computer': 		subject += os;				break;
                case 'Phone/Tablet': 	subject += 'Mobile ' + os;	break;
                default: 				subject += 'Unknown';
            }

            obj.category1 = 'Desktop Management';
            obj.category2 = 'Software';
            obj.category3 = 'Error';
            break;

        case 'Hardware':
            subject += 'HW';
            obj.category1 = 'Desktop Management';
            obj.category2 = 'Hardware';
            obj.category3 = 'Failure';
            break;

        case 'Office365':
            subject += 'O365';
            obj.category1 = 'Application Management';
            obj.category2 = 'Software';
            obj.category3 = 'Error';
            break;

        case 'OS Troubleshooting':
            if(os === 'N/A') os = walkin.otherDevice;
            else if(os.indexOf('(') >= 0) os = os.substring(0, os.indexOf('(')).trim();
            subject += 'OS TblSh ' + os;

            obj.category1 = 'Desktop Management';
            obj.category2 = 'OS/Firmware';
            obj.category3 = 'Error';
            break;

        case 'Password Resets':
            subject += 'PwdReset';

            obj.category1 = 'Application Management';
            obj.category2 = 'Access';
            obj.category3 = 'Inaccessible';<commit_msg>Update SN template<commit_after>    'use strict';

/**
 * Module dependencies.
 */
var mongoose = require('mongoose'),
    _ = require('lodash'),
    request = require('request'),
    soap = require('soap'),
    fs = require('fs'),
    async = require('async'),
    Walkin = mongoose.model('Walkin'),
    Checkin = mongoose.model('Checkin'),
    ContactLog = mongoose.model('ContactLog');

// Get credentials (& reformat wsdl url)
var credentialFilePath = __dirname + '/../../credentials/ServiceNow.json',
    credentialFile = fs.readFileSync(credentialFilePath, 'utf8'),
    credential = JSON.parse(credentialFile);

if(credential.username){
    var index = credential.wsdl_url.indexOf('//') + '//'.length;
    credential.wsdl_url = credential.wsdl_url.substring(0, index) + credential.username + ':' + credential.password + '@' + credential.wsdl_url.substring(index);
}

var popOpt_walkin = [
    { path : 'user', model : 'User', select : 'username'},
    { path : 'lastUpdateTechnician', model : 'User', select : 'username'},
    { path : 'serviceTechnician', model : 'User', select : 'username'},
    { path : 'resoluteTechnician', model : 'User', select : 'username'}
];

var popOpt_checkin = [
    { path : 'user', model : 'User', select : 'firstName lastName displayName username phone location verified'},
    { path : 'walkin', model : 'Walkin', select : 'description resoluteTechnician deviceCategory deviceType os otherDevice'},
    { path : 'serviceLog', model : 'ServiceEntry', select : 'type description createdBy createdAt'},
    { path : 'completionTechnician', model : 'User', select : 'username displayName'},
    { path : 'verificationTechnician', model : 'User', select : 'username displayName'},
    { path : 'checkoutTechnician', model : 'User', select : 'username displayName'},
    { path : 'contactLog', model : 'ContactLog'}
];

var popOpt_checkin_walkin = [{ path : 'walkin.resoluteTechnician',  model : 'User', select : 'username displayName'}];

var getWalkinTemplateObj = function(walkin){
    var subject = 'STS: ', os = walkin.os;
    var obj = { short_description: '', category1 : '', category2 : '', category3 : '' };

    switch(walkin.resolutionType){
        case 'DooleyNet':
            subject += 'DN ' + walkin.deviceType;
            if(walkin.deviceType === 'Other') subject += ' ' + walkin.otherDevice;

            obj.type = 'Service Request';
            obj.category1 = 'Application Management';
            obj.category2 = 'Access';
            obj.category3 = 'Inaccessible';
            break;

        case 'EmoryUnplugged':
            subject += 'EU ';
            if(os === 'N/A') os = walkin.otherDevice;
            else if(os.indexOf('(') >= 0) os = os.substring(0, os.indexOf('(')).trim();

            switch(walkin.deviceCategory){
                case 'Computer': 		subject += os;				break;
                case 'Phone/Tablet': 	subject += 'Mobile ' + os;	break;
                default: 				subject += 'Unknown';
            }

            obj.category1 = 'Desktop Management';
            obj.category2 = 'Software';
            obj.category3 = 'Error';
            break;

        case 'Hardware':
            subject += 'HW';
            obj.category1 = 'Desktop Management';
            obj.category2 = 'Hardware';
            obj.category3 = 'Failure';
            break;

        case 'Office365':
            subject += 'O365';
            obj.category1 = 'Application Management';
            obj.category2 = 'Software';
            obj.category3 = 'Error';
            break;

        case 'OS Troubleshooting':
            if(os === 'N/A') os = walkin.otherDevice;
            else if(os.indexOf('(') >= 0) os = os.substring(0, os.indexOf('(')).trim();
            subject += 'OS TblSh ' + os;

            obj.category1 = 'Desktop Management';
            obj.category2 = 'OS/Firmware';
            obj.category3 = 'Error';
            break;

        case 'Password Resets':
            subject += 'PwdReset';

            obj.category1 = 'Application Management';
            obj.category2 = 'Access';
            obj.category3 = 'Inaccessible';
            break;

        case 'Printing':
            subject += 'Printing';

            obj.category1 = 'Print Management';
            obj.category2 = 'User Printing';
            obj.category3 = 'Inaccessible';
{'fraction_non_alphanumeric': 0.15068007096392666, 'fraction_numerical': 0.008160851567120047, 'mean_word_length': 2.4669946699466996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2560035', 'n_tokens_mistral': 2475, 'n_tokens_neox': 2373, 'n_words': 564}