Built motion from commit 1ea47bf4.|2.6.34
[motion2.git] / server / api / jscriptyProject / jscriptyProject.controller.js
index c60cb32..e8e0a1e 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x936d=['indexOf','replace','getSummary','startTime','parse','-createdAt','questionId','question','starttime','format','SessionId','push','isEmpty','now','/tmp/Jscripty_Project_%d_Summary_%s.csv','Content-disposition','attachment;\x20filename=','setHeader','Content-type','text/csv','download','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','offset','undefined','limit','count','Content-Range','json','reject','save','update','then','Projects','UserProfileResource','destroy','error','stack','name','send','index','JscriptyProject','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','VIRTUAL','options','includeAll','findAll','rows','catch','show','rawAttributes','length','include','find','create','body','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','omit','createdAt','updatedAt','userProfileId','getSessions','findOne','JscriptySessionReport','getAnswers','JscriptyAnswerReport','ProjectId','number','fromCharCode','apply','toString'];(function(_0x546f2f,_0x371be9){var _0x3eb416=function(_0x161a2b){while(--_0x161a2b){_0x546f2f['push'](_0x546f2f['shift']());}};_0x3eb416(++_0x371be9);}(_0x936d,0x183));var _0xd936=function(_0x4f4716,_0x915f74){_0x4f4716=_0x4f4716-0x0;var _0x452a6f=_0x936d[_0x4f4716];return _0x452a6f;};'use strict';var emlformat=require(_0xd936('0x0'));var rimraf=require(_0xd936('0x1'));var zipdir=require(_0xd936('0x2'));var jsonpatch=require(_0xd936('0x3'));var rp=require('request-promise');var moment=require(_0xd936('0x4'));var BPromise=require(_0xd936('0x5'));var Mustache=require(_0xd936('0x6'));var util=require(_0xd936('0x7'));var path=require(_0xd936('0x8'));var sox=require(_0xd936('0x9'));var csv=require(_0xd936('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xd936('0xb'));var _=require(_0xd936('0xc'));var squel=require(_0xd936('0xd'));var crypto=require(_0xd936('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xd936('0xf'));var toCsv=require(_0xd936('0xa'));var querystring=require('querystring');var Papa=require(_0xd936('0x10'));var Redis=require(_0xd936('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xd936('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xd936('0x13'));var logger=require(_0xd936('0x14'))(_0xd936('0x15'));var utils=require(_0xd936('0x16'));var config=require(_0xd936('0x17'));var licenseUtil=require(_0xd936('0x18'));var db=require(_0xd936('0x19'))['db'];function respondWithStatusCode(_0x434d80,_0x309978){_0x309978=_0x309978||0xcc;return function(_0x884e08){if(_0x884e08){return _0x434d80[_0xd936('0x1a')](_0x309978);}return _0x434d80[_0xd936('0x1b')](_0x309978)['end']();};}function respondWithResult(_0x39153f,_0x1feab7){_0x1feab7=_0x1feab7||0xc8;return function(_0xae89f4){if(_0xae89f4){return _0x39153f['status'](_0x1feab7)['json'](_0xae89f4);}};}function respondWithFilteredResult(_0x520168,_0x39627b){return function(_0x38a890){if(_0x38a890){var _0x26d441=typeof _0x39627b[_0xd936('0x1c')]===_0xd936('0x1d')&&typeof _0x39627b[_0xd936('0x1e')]===_0xd936('0x1d');var _0x262eb8=_0x38a890[_0xd936('0x1f')];var _0x1d5805=_0x26d441?0x0:_0x39627b['offset'];var _0x35011a=_0x26d441?_0x38a890[_0xd936('0x1f')]:_0x39627b['offset']+_0x39627b[_0xd936('0x1e')];var _0x48d37b;if(_0x35011a>=_0x262eb8){_0x35011a=_0x262eb8;_0x48d37b=0xc8;}else{_0x48d37b=0xce;}_0x520168[_0xd936('0x1b')](_0x48d37b);return _0x520168['set'](_0xd936('0x20'),_0x1d5805+'-'+_0x35011a+'/'+_0x262eb8)[_0xd936('0x21')](_0x38a890);}return null;};}function patchUpdates(_0x10c05d){return function(_0x2568dd){try{jsonpatch['apply'](_0x2568dd,_0x10c05d,!![]);}catch(_0x160927){return BPromise[_0xd936('0x22')](_0x160927);}return _0x2568dd[_0xd936('0x23')]();};}function saveUpdates(_0x382585,_0x310e5a){return function(_0x4a7f3a){if(_0x4a7f3a){return _0x4a7f3a[_0xd936('0x24')](_0x382585)[_0xd936('0x25')](function(_0x44e631){return _0x44e631;});}return null;};}function removeEntity(_0x29f419,_0x22b726){return function(_0x17f4c9){if(_0x17f4c9){return _0x17f4c9['destroy']()[_0xd936('0x25')](function(){var _0x2a96c3=_0x17f4c9['get']({'plain':!![]});var _0x39d5c3=_0xd936('0x26');return db[_0xd936('0x27')][_0xd936('0x28')]({'where':{'type':_0x39d5c3,'resourceId':_0x2a96c3['id']}})['then'](function(){return _0x17f4c9;});})[_0xd936('0x25')](function(){_0x29f419['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x2de3fa,_0x1df51c){return function(_0x33b3b7){if(!_0x33b3b7){_0x2de3fa[_0xd936('0x1a')](0x194);}return _0x33b3b7;};}function handleError(_0x441c0f,_0x3f0f9e){_0x3f0f9e=_0x3f0f9e||0x1f4;return function(_0x3c8d92){logger[_0xd936('0x29')](_0x3c8d92[_0xd936('0x2a')]);if(_0x3c8d92['name']){delete _0x3c8d92[_0xd936('0x2b')];}_0x441c0f[_0xd936('0x1b')](_0x3f0f9e)[_0xd936('0x2c')](_0x3c8d92);};}exports[_0xd936('0x2d')]=function(_0x4c416a,_0x41b003){var _0x99d672={},_0x4872ca={},_0x11ea10={'count':0x0,'rows':[]};var _0x4087a2=_['map'](db[_0xd936('0x2e')]['rawAttributes'],function(_0x301202){return{'name':_0x301202[_0xd936('0x2f')],'type':_0x301202[_0xd936('0x30')][_0xd936('0x31')]};});_0x4872ca['model']=_['map'](_0x4087a2,_0xd936('0x2b'));_0x4872ca[_0xd936('0x32')]=_[_0xd936('0x33')](_0x4c416a[_0xd936('0x32')]);_0x4872ca[_0xd936('0x34')]=_[_0xd936('0x35')](_0x4872ca[_0xd936('0x36')],_0x4872ca[_0xd936('0x32')]);_0x99d672[_0xd936('0x37')]=_[_0xd936('0x35')](_0x4872ca[_0xd936('0x36')],qs['fields'](_0x4c416a['query'][_0xd936('0x38')]));_0x99d672['attributes']=_0x99d672[_0xd936('0x37')]['length']?_0x99d672[_0xd936('0x37')]:_0x4872ca[_0xd936('0x36')];if(!_0x4c416a[_0xd936('0x32')][_0xd936('0x39')](_0xd936('0x3a'))){_0x99d672[_0xd936('0x1e')]=qs[_0xd936('0x1e')](_0x4c416a[_0xd936('0x32')][_0xd936('0x1e')]);_0x99d672['offset']=qs[_0xd936('0x1c')](_0x4c416a['query']['offset']);}_0x99d672[_0xd936('0x3b')]=qs['sort'](_0x4c416a['query'][_0xd936('0x3c')]);_0x99d672[_0xd936('0x3d')]=qs[_0xd936('0x34')](_[_0xd936('0x3e')](_0x4c416a[_0xd936('0x32')],_0x4872ca[_0xd936('0x34')]),_0x4087a2);if(_0x4c416a['query'][_0xd936('0x3f')]){_0x99d672[_0xd936('0x3d')]=_[_0xd936('0x40')](_0x99d672[_0xd936('0x3d')],{'$or':_[_0xd936('0x41')](_0x4087a2,function(_0x364f5f){if(_0x364f5f['type']!==_0xd936('0x42')){var _0x203d6e={};_0x203d6e[_0x364f5f[_0xd936('0x2b')]]={'$like':'%'+_0x4c416a[_0xd936('0x32')]['filter']+'%'};return _0x203d6e;}})});}_0x99d672=_[_0xd936('0x40')]({},_0x99d672,_0x4c416a[_0xd936('0x43')]);var _0x5b21bf={'where':_0x99d672[_0xd936('0x3d')]};return db[_0xd936('0x2e')][_0xd936('0x1f')](_0x5b21bf)[_0xd936('0x25')](function(_0x33ad69){_0x11ea10[_0xd936('0x1f')]=_0x33ad69;if(_0x4c416a[_0xd936('0x32')][_0xd936('0x44')]){_0x99d672['include']=[{'all':!![]}];}return db['JscriptyProject'][_0xd936('0x45')](_0x99d672);})['then'](function(_0x16fd53){_0x11ea10[_0xd936('0x46')]=_0x16fd53;return _0x11ea10;})[_0xd936('0x25')](respondWithFilteredResult(_0x41b003,_0x99d672))[_0xd936('0x47')](handleError(_0x41b003,null));};exports[_0xd936('0x48')]=function(_0xb4d47b,_0x1d9c4c){var _0x24a141={'raw':![],'where':{'id':_0xb4d47b['params']['id']}},_0x391c33={};_0x391c33[_0xd936('0x36')]=_['keys'](db[_0xd936('0x2e')][_0xd936('0x49')]);_0x391c33[_0xd936('0x32')]=_[_0xd936('0x33')](_0xb4d47b[_0xd936('0x32')]);_0x391c33['filters']=_[_0xd936('0x35')](_0x391c33['model'],_0x391c33[_0xd936('0x32')]);_0x24a141['attributes']=_['intersection'](_0x391c33[_0xd936('0x36')],qs['fields'](_0xb4d47b[_0xd936('0x32')]['fields']));_0x24a141[_0xd936('0x37')]=_0x24a141['attributes'][_0xd936('0x4a')]?_0x24a141['attributes']:_0x391c33['model'];if(_0xb4d47b[_0xd936('0x32')][_0xd936('0x44')]){_0x24a141[_0xd936('0x4b')]=[{'all':!![]}];}_0x24a141=_[_0xd936('0x40')]({},_0x24a141,_0xb4d47b[_0xd936('0x43')]);return db[_0xd936('0x2e')][_0xd936('0x4c')](_0x24a141)[_0xd936('0x25')](handleEntityNotFound(_0x1d9c4c,null))[_0xd936('0x25')](respondWithResult(_0x1d9c4c,null))['catch'](handleError(_0x1d9c4c,null));};exports['create']=function(_0x1762f0,_0x1e7ace){return db[_0xd936('0x2e')][_0xd936('0x4d')](_0x1762f0[_0xd936('0x4e')],{})[_0xd936('0x25')](function(_0x4c9e5d){var _0x47f932=_0x1762f0['user'][_0xd936('0x4f')]({'plain':!![]});if(!_0x47f932)throw new Error(_0xd936('0x50'));if(_0x47f932[_0xd936('0x51')]===_0xd936('0x52')){var _0x4bdb1c=_0x4c9e5d[_0xd936('0x4f')]({'plain':!![]});var _0x42631e='Projects';return db[_0xd936('0x53')][_0xd936('0x4c')]({'where':{'name':_0x42631e,'userProfileId':_0x47f932['userProfileId']},'raw':!![]})[_0xd936('0x25')](function(_0x27887c){if(_0x27887c&&_0x27887c[_0xd936('0x54')]===0x0){return db[_0xd936('0x27')][_0xd936('0x4d')]({'name':_0x4bdb1c['name'],'resourceId':_0x4bdb1c['id'],'type':_0x27887c[_0xd936('0x2b')],'sectionId':_0x27887c['id']},{})[_0xd936('0x25')](function(){return _0x4c9e5d;});}else{return _0x4c9e5d;}})[_0xd936('0x47')](function(_0x427972){logger[_0xd936('0x29')](_0xd936('0x55'),_0x427972);throw _0x427972;});}return _0x4c9e5d;})['then'](respondWithResult(_0x1e7ace,0xc9))['catch'](handleError(_0x1e7ace,null));};exports['clone']=function(_0x1a3a80,_0x5140a2){var _0xa5c81f={'where':{'id':_0x1a3a80[_0xd936('0x56')]['id']}},_0x3860ab={};_0x3860ab[_0xd936('0x36')]=_[_0xd936('0x33')](db[_0xd936('0x2e')][_0xd936('0x49')]);_0xa5c81f[_0xd936('0x37')]=_['intersection'](_0x3860ab[_0xd936('0x36')],qs[_0xd936('0x38')](_0x1a3a80[_0xd936('0x32')][_0xd936('0x38')]));_0xa5c81f[_0xd936('0x37')]=_0xa5c81f['attributes'][_0xd936('0x4a')]?_0xa5c81f['attributes']:_0x3860ab[_0xd936('0x36')];if(_0x1a3a80[_0xd936('0x32')][_0xd936('0x44')]){_0xa5c81f['include']=[{'all':!![]}];}_0xa5c81f=_[_0xd936('0x40')]({},_0xa5c81f,_0x1a3a80['options']);return db[_0xd936('0x2e')][_0xd936('0x4c')](_0xa5c81f)[_0xd936('0x25')](handleEntityNotFound(_0x5140a2,null))['then'](function(_0x332342){if(_0x332342){var _0x55f0b7=_0x332342[_0xd936('0x4f')]({'plain':!![]});_0x55f0b7=qs[_0xd936('0x57')](_0x55f0b7,['id',_0xd936('0x58'),_0xd936('0x59')]);_0x1a3a80['body']=_[_0xd936('0x57')](_0x1a3a80[_0xd936('0x4e')],['id',_0xd936('0x58'),_0xd936('0x59')]);return db[_0xd936('0x2e')][_0xd936('0x4d')](_[_0xd936('0x40')](_0x55f0b7,_0x1a3a80[_0xd936('0x4e')]),{'include':_0x1a3a80['query'][_0xd936('0x44')]?[{'all':!![]}]:undefined})['then'](function(_0x5c2129){var _0x49bebb=_0x1a3a80[_0xd936('0x52')]['get']({'plain':!![]});if(!_0x49bebb)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x49bebb['role']==='user'){var _0x1838fb=_0x5c2129[_0xd936('0x4f')]({'plain':!![]});var _0x4b50a0=_0xd936('0x26');return db[_0xd936('0x53')]['find']({'where':{'name':_0x4b50a0,'userProfileId':_0x49bebb[_0xd936('0x5a')]},'raw':!![]})[_0xd936('0x25')](function(_0x41a12e){if(_0x41a12e&&_0x41a12e[_0xd936('0x54')]===0x0){return db[_0xd936('0x27')][_0xd936('0x4d')]({'name':_0x1838fb['name'],'resourceId':_0x1838fb['id'],'type':_0x41a12e['name'],'sectionId':_0x41a12e['id']},{})['then'](function(){return _0x5c2129;});}else{return _0x5c2129;}})[_0xd936('0x47')](function(_0x269260){logger[_0xd936('0x29')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x269260);throw _0x269260;});}return _0x5c2129;});}})[_0xd936('0x25')](respondWithResult(_0x5140a2,0xc9))[_0xd936('0x47')](handleError(_0x5140a2,null));};exports[_0xd936('0x24')]=function(_0x55030d,_0x4aeac0){if(_0x55030d[_0xd936('0x4e')]['id']){delete _0x55030d['body']['id'];}return db[_0xd936('0x2e')][_0xd936('0x4c')]({'where':{'id':_0x55030d[_0xd936('0x56')]['id']}})[_0xd936('0x25')](handleEntityNotFound(_0x4aeac0,null))[_0xd936('0x25')](saveUpdates(_0x55030d['body'],null))[_0xd936('0x25')](respondWithResult(_0x4aeac0,null))[_0xd936('0x47')](handleError(_0x4aeac0,null));};exports[_0xd936('0x28')]=function(_0x302529,_0x1da5c8){return db[_0xd936('0x2e')][_0xd936('0x4c')]({'where':{'id':_0x302529['params']['id']}})[_0xd936('0x25')](handleEntityNotFound(_0x1da5c8,null))[_0xd936('0x25')](removeEntity(_0x1da5c8,null))[_0xd936('0x47')](handleError(_0x1da5c8,null));};exports[_0xd936('0x5b')]=function(_0x237aac,_0x3b56b3,_0x549b6b){var _0x5ec004={'raw':!![],'where':{}};var _0x4f2baf={};var _0xdea2bd={'count':0x0,'rows':[]};return db['JscriptyProject'][_0xd936('0x5c')]({'where':{'id':_0x237aac[_0xd936('0x56')]['id']}})['then'](handleEntityNotFound(_0x3b56b3,null))['then'](function(_0x6e7684){if(_0x6e7684){_0x4f2baf['model']=_[_0xd936('0x33')](db[_0xd936('0x5d')][_0xd936('0x49')]);_0x4f2baf['query']=_[_0xd936('0x33')](_0x237aac[_0xd936('0x32')]);_0x4f2baf[_0xd936('0x34')]=_['intersection'](_0x4f2baf['model'],_0x4f2baf[_0xd936('0x32')]);_0x5ec004[_0xd936('0x37')]=_[_0xd936('0x35')](_0x4f2baf['model'],qs[_0xd936('0x38')](_0x237aac[_0xd936('0x32')][_0xd936('0x38')]));_0x5ec004[_0xd936('0x37')]=_0x5ec004[_0xd936('0x37')]['length']?_0x5ec004['attributes']:_0x4f2baf[_0xd936('0x36')];if(!_0x237aac[_0xd936('0x32')][_0xd936('0x39')]('nolimit')){_0x5ec004[_0xd936('0x1e')]=qs['limit'](_0x237aac[_0xd936('0x32')]['limit']);_0x5ec004[_0xd936('0x1c')]=qs[_0xd936('0x1c')](_0x237aac[_0xd936('0x32')]['offset']);}_0x5ec004[_0xd936('0x3b')]=qs[_0xd936('0x3c')](_0x237aac[_0xd936('0x32')][_0xd936('0x3c')]);_0x5ec004['where']=qs[_0xd936('0x34')](_[_0xd936('0x3e')](_0x237aac['query'],_0x4f2baf[_0xd936('0x34')]));_0x5ec004[_0xd936('0x3d')]['ProjectId']=_0x6e7684['id'];if(_0x237aac[_0xd936('0x32')][_0xd936('0x3f')]){_0x5ec004[_0xd936('0x3d')]=_[_0xd936('0x40')](_0x5ec004[_0xd936('0x3d')],{'$or':_[_0xd936('0x41')](_0x5ec004[_0xd936('0x37')],function(_0x365ae1){var _0x10601f={};_0x10601f[_0x365ae1]={'$like':'%'+_0x237aac[_0xd936('0x32')][_0xd936('0x3f')]+'%'};return _0x10601f;})});}_0x5ec004=_[_0xd936('0x40')]({},_0x5ec004,_0x237aac[_0xd936('0x43')]);return db['JscriptySessionReport']['count']({'where':_0x5ec004[_0xd936('0x3d')]})[_0xd936('0x25')](function(_0x1e410d){_0xdea2bd[_0xd936('0x1f')]=_0x1e410d;if(_0x237aac[_0xd936('0x32')][_0xd936('0x44')]){_0x5ec004[_0xd936('0x4b')]=[{'all':!![]}];}return db[_0xd936('0x5d')]['findAll'](_0x5ec004);})['then'](function(_0x2cb900){_0xdea2bd['rows']=_0x2cb900;return _0xdea2bd;});}})['then'](respondWithFilteredResult(_0x3b56b3,_0x5ec004))[_0xd936('0x47')](handleError(_0x3b56b3,null));};exports[_0xd936('0x5e')]=function(_0xd8a27,_0x536000,_0xd77cad){var _0x478a5c={'raw':!![],'where':{}};var _0x534959={};var _0x45ca8f={'count':0x0,'rows':[]};return db[_0xd936('0x2e')]['findOne']({'where':{'id':_0xd8a27['params']['id']}})[_0xd936('0x25')](handleEntityNotFound(_0x536000,null))['then'](function(_0x2881e1){if(_0x2881e1){_0x534959['model']=_[_0xd936('0x33')](db[_0xd936('0x5f')]['rawAttributes']);_0x534959[_0xd936('0x32')]=_[_0xd936('0x33')](_0xd8a27[_0xd936('0x32')]);_0x534959[_0xd936('0x34')]=_[_0xd936('0x35')](_0x534959['model'],_0x534959[_0xd936('0x32')]);_0x478a5c[_0xd936('0x37')]=_[_0xd936('0x35')](_0x534959[_0xd936('0x36')],qs[_0xd936('0x38')](_0xd8a27[_0xd936('0x32')][_0xd936('0x38')]));_0x478a5c[_0xd936('0x37')]=_0x478a5c[_0xd936('0x37')][_0xd936('0x4a')]?_0x478a5c[_0xd936('0x37')]:_0x534959['model'];if(!_0xd8a27[_0xd936('0x32')][_0xd936('0x39')](_0xd936('0x3a'))){_0x478a5c[_0xd936('0x1e')]=qs[_0xd936('0x1e')](_0xd8a27[_0xd936('0x32')][_0xd936('0x1e')]);_0x478a5c[_0xd936('0x1c')]=qs[_0xd936('0x1c')](_0xd8a27['query'][_0xd936('0x1c')]);}_0x478a5c['order']=qs['sort'](_0xd8a27['query'][_0xd936('0x3c')]);_0x478a5c['where']=qs[_0xd936('0x34')](_[_0xd936('0x3e')](_0xd8a27[_0xd936('0x32')],_0x534959[_0xd936('0x34')]));_0x478a5c[_0xd936('0x3d')][_0xd936('0x60')]=_0x2881e1['id'];if(_0xd8a27['query']['filter']){_0x478a5c[_0xd936('0x3d')]=_[_0xd936('0x40')](_0x478a5c[_0xd936('0x3d')],{'$or':_['map'](_0x478a5c[_0xd936('0x37')],function(_0x13b096){var _0x126e60={};_0x126e60[_0x13b096]={'$like':'%'+_0xd8a27[_0xd936('0x32')][_0xd936('0x3f')]+'%'};return _0x126e60;})});}_0x478a5c=_[_0xd936('0x40')]({},_0x478a5c,_0xd8a27[_0xd936('0x43')]);return db[_0xd936('0x5f')]['count']({'where':_0x478a5c['where']})[_0xd936('0x25')](function(_0x1cc3d7){_0x45ca8f[_0xd936('0x1f')]=_0x1cc3d7;if(_0xd8a27[_0xd936('0x32')][_0xd936('0x44')]){_0x478a5c[_0xd936('0x4b')]=[{'all':!![]}];}return db[_0xd936('0x5f')]['findAll'](_0x478a5c);})[_0xd936('0x25')](function(_0x3d1b78){_0x45ca8f[_0xd936('0x46')]=_0x3d1b78;return _0x45ca8f;});}})[_0xd936('0x25')](respondWithFilteredResult(_0x536000,_0x478a5c))[_0xd936('0x47')](handleError(_0x536000,null));};function char(_0x3b94a2){return _0xd936('0x61')===typeof _0x3b94a2?String[_0xd936('0x62')][_0xd936('0x63')](null,arguments):_0x3b94a2;}function needsEncapsulation(_0x3faafa){return!!_0x3faafa&&(_0x3faafa[_0xd936('0x64')]()[_0xd936('0x65')](char(0xd))>=0x0||_0x3faafa[_0xd936('0x64')]()[_0xd936('0x65')](char(0xa))>=0x0||_0x3faafa[_0xd936('0x64')]()[_0xd936('0x65')](char(0x2c))>=0x0||_0x3faafa[_0xd936('0x64')]()[_0xd936('0x65')](char(0x22))>=0x0);}function encapsulate(_0x685a12){var _0x30ea1b=char(0x22),_0x474a3e='\x5c'+char(0x22),_0x7dc026=_0x685a12[_0xd936('0x64')]()[_0xd936('0x66')](new RegExp(_0x30ea1b,'g'),_0x474a3e);return _0x30ea1b+_0x7dc026+_0x30ea1b;}exports[_0xd936('0x67')]=function(_0x3ce5f1,_0x18b5e1,_0x1e072a){var _0x552c76,_0x2188c1;var _0x1f2d29={'where':{'ProjectId':_0x3ce5f1[_0xd936('0x56')]['id']}};if(_0x3ce5f1[_0xd936('0x32')][_0xd936('0x68')]){_0x1f2d29[_0xd936('0x3d')]['starttime']=JSON[_0xd936('0x69')](_0x3ce5f1[_0xd936('0x32')]['startTime']);}return db[_0xd936('0x5d')][_0xd936('0x45')](_0x1f2d29)[_0xd936('0x25')](handleEntityNotFound(_0x18b5e1,null))[_0xd936('0x25')](function(_0x15a1f3){if(_0x15a1f3){_0x552c76=_0x15a1f3;return db['JscriptyQuestionReport'][_0xd936('0x45')]({'where':{'SessionId':{'$in':_[_0xd936('0x41')](_0x552c76,'id')},'ProjectId':_0x3ce5f1['params']['id']},'order':_0xd936('0x6a')});}})[_0xd936('0x25')](handleEntityNotFound(_0x18b5e1,null))[_0xd936('0x25')](function(_0x5046c5){if(_0x5046c5){_0x2188c1=_0x5046c5;var _0x38f3e7={};for(var _0x1699dc=0x0,_0x274cfa=_0x2188c1[_0xd936('0x4a')];_0x1699dc<_0x274cfa;_0x1699dc++){if(!_0x38f3e7[_0xd936('0x39')](_0x2188c1[_0x1699dc][_0xd936('0x6b')])){_0x38f3e7[_0x2188c1[_0x1699dc][_0xd936('0x6b')]]=needsEncapsulation(_0x2188c1[_0x1699dc][_0xd936('0x6c')])?encapsulate(_0x2188c1[_0x1699dc][_0xd936('0x6c')]):_0x2188c1[_0x1699dc]['question'];}}var _0x575cd4=[],_0x290492={};for(var _0x41c65e=0x0,_0x1d8f12=_0x552c76[_0xd936('0x4a')];_0x41c65e<_0x1d8f12;_0x41c65e++){_0x290492={'ProjectId':_0x3ce5f1[_0xd936('0x56')]['id'],'SessionId':_0x552c76[_0x41c65e]['id'],'StartTime':moment(_0x552c76[_0x41c65e][_0xd936('0x6d')])[_0xd936('0x6e')]('YYYY-MM-DD\x20HH:mm:ss')};for(var _0x302f24=0x0,_0x25f353=_0x2188c1[_0xd936('0x4a')];_0x302f24<_0x25f353;_0x302f24++){if(_0x2188c1[_0x302f24][_0xd936('0x6f')]==_0x552c76[_0x41c65e]['id']&&_0x38f3e7['hasOwnProperty'](_0x2188c1[_0x302f24][_0xd936('0x6b')])){_0x290492[_0x38f3e7[_0x2188c1[_0x302f24]['questionId']]]=_0x2188c1[_0x302f24]['answer'];}}for(var _0x4a6786 in _0x38f3e7){if(!_0x290492['hasOwnProperty'](_0x38f3e7[_0x4a6786])){_0x290492[_0x38f3e7[_0x4a6786]]=null;}}_0x575cd4[_0xd936('0x70')](_0x290492);}return _0x575cd4;}})[_0xd936('0x25')](function(_0x2e0a91){if(!_[_0xd936('0x71')](_0x2e0a91)){var _0x5be4dc=toCsv(_0x2e0a91);var _0xca355=Date[_0xd936('0x72')]();fs['writeFileSync'](util[_0xd936('0x6e')](_0xd936('0x73'),_0x3ce5f1[_0xd936('0x56')]['id'],_0xca355),_0x5be4dc);_0x18b5e1['setHeader'](_0xd936('0x74'),_0xd936('0x75')+util[_0xd936('0x6e')]('Jscripty_Project_%d_Summary_%s.csv',_0x3ce5f1['params']['id'],_0xca355));_0x18b5e1[_0xd936('0x76')](_0xd936('0x77'),_0xd936('0x78'));return _0x18b5e1[_0xd936('0x79')](util[_0xd936('0x6e')](_0xd936('0x73'),_0x3ce5f1['params']['id'],_0xca355));}else{return _0x18b5e1['sendStatus'](0xcc);}})[_0xd936('0x47')](handleError(_0x18b5e1,null));};
\ No newline at end of file
+var _0x73f5=['undefined','limit','count','set','Content-Range','json','apply','reject','save','update','then','destroy','Projects','UserProfileResource','end','error','stack','name','index','map','rawAttributes','fieldName','type','key','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','where','pick','filter','merge','VIRTUAL','options','JscriptyProject','includeAll','include','rows','catch','show','params','model','keys','length','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','get','UserProfileSection','find','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','omit','createdAt','updatedAt','body','autoAssociation','findOne','JscriptySessionReport','ProjectId','getAnswers','JscriptyAnswerReport','order','findAll','number','toString','indexOf','replace','getSummary','starttime','parse','startTime','-createdAt','questionId','question','YYYY-MM-DD\x20HH:mm:ss','SessionId','answer','isEmpty','now','writeFileSync','format','/tmp/Jscripty_Project_%d_Summary_%s.csv','setHeader','Content-disposition','attachment;\x20filename=','Jscripty_Project_%d_Summary_%s.csv','Content-type','text/csv','download','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','squel','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','sendStatus','status','offset'];(function(_0xdea41a,_0x552987){var _0x15d0d8=function(_0x1e0d0b){while(--_0x1e0d0b){_0xdea41a['push'](_0xdea41a['shift']());}};_0x15d0d8(++_0x552987);}(_0x73f5,0x1cb));var _0x573f=function(_0x413c45,_0x3000c7){_0x413c45=_0x413c45-0x0;var _0x5764d6=_0x73f5[_0x413c45];return _0x5764d6;};'use strict';var emlformat=require(_0x573f('0x0'));var rimraf=require(_0x573f('0x1'));var zipdir=require(_0x573f('0x2'));var jsonpatch=require(_0x573f('0x3'));var rp=require('request-promise');var moment=require(_0x573f('0x4'));var BPromise=require(_0x573f('0x5'));var Mustache=require(_0x573f('0x6'));var util=require(_0x573f('0x7'));var path=require(_0x573f('0x8'));var sox=require(_0x573f('0x9'));var csv=require(_0x573f('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x573f('0xb'));var _=require('lodash');var squel=require(_0x573f('0xc'));var crypto=require('crypto');var jsforce=require(_0x573f('0xd'));var deskjs=require('desk.js');var toCsv=require(_0x573f('0xa'));var querystring=require(_0x573f('0xe'));var Papa=require(_0x573f('0xf'));var Redis=require('ioredis');var authService=require(_0x573f('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x573f('0x11'));var hardwareService=require(_0x573f('0x12'));var logger=require(_0x573f('0x13'))(_0x573f('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x573f('0x15'))['db'];function respondWithStatusCode(_0x2493f3,_0x11ea43){_0x11ea43=_0x11ea43||0xcc;return function(_0x322304){if(_0x322304){return _0x2493f3[_0x573f('0x16')](_0x11ea43);}return _0x2493f3['status'](_0x11ea43)['end']();};}function respondWithResult(_0x57290c,_0x2718bd){_0x2718bd=_0x2718bd||0xc8;return function(_0x149144){if(_0x149144){return _0x57290c[_0x573f('0x17')](_0x2718bd)['json'](_0x149144);}};}function respondWithFilteredResult(_0x3550bf,_0x544e9f){return function(_0x55d73f){if(_0x55d73f){var _0x51c32d=typeof _0x544e9f[_0x573f('0x18')]===_0x573f('0x19')&&typeof _0x544e9f[_0x573f('0x1a')]===_0x573f('0x19');var _0x3c1584=_0x55d73f['count'];var _0x4de5ef=_0x51c32d?0x0:_0x544e9f[_0x573f('0x18')];var _0x1202c8=_0x51c32d?_0x55d73f[_0x573f('0x1b')]:_0x544e9f['offset']+_0x544e9f[_0x573f('0x1a')];var _0x3d4253;if(_0x1202c8>=_0x3c1584){_0x1202c8=_0x3c1584;_0x3d4253=0xc8;}else{_0x3d4253=0xce;}_0x3550bf[_0x573f('0x17')](_0x3d4253);return _0x3550bf[_0x573f('0x1c')](_0x573f('0x1d'),_0x4de5ef+'-'+_0x1202c8+'/'+_0x3c1584)[_0x573f('0x1e')](_0x55d73f);}return null;};}function patchUpdates(_0x5c4308){return function(_0x77ba9f){try{jsonpatch[_0x573f('0x1f')](_0x77ba9f,_0x5c4308,!![]);}catch(_0x3eebba){return BPromise[_0x573f('0x20')](_0x3eebba);}return _0x77ba9f[_0x573f('0x21')]();};}function saveUpdates(_0x1fd5e4,_0x5f5f48){return function(_0x206e5d){if(_0x206e5d){return _0x206e5d[_0x573f('0x22')](_0x1fd5e4)[_0x573f('0x23')](function(_0x3da73b){return _0x3da73b;});}return null;};}function removeEntity(_0x31dfe8,_0x429f2b){return function(_0x10eda6){if(_0x10eda6){return _0x10eda6[_0x573f('0x24')]()[_0x573f('0x23')](function(){var _0x3acd35=_0x10eda6['get']({'plain':!![]});var _0x50139c=_0x573f('0x25');return db[_0x573f('0x26')]['destroy']({'where':{'type':_0x50139c,'resourceId':_0x3acd35['id']}})['then'](function(){return _0x10eda6;});})[_0x573f('0x23')](function(){_0x31dfe8[_0x573f('0x17')](0xcc)[_0x573f('0x27')]();});}};}function handleEntityNotFound(_0x54ae1a,_0x32c273){return function(_0x146975){if(!_0x146975){_0x54ae1a[_0x573f('0x16')](0x194);}return _0x146975;};}function handleError(_0x253e2c,_0x343296){_0x343296=_0x343296||0x1f4;return function(_0x54eef1){logger[_0x573f('0x28')](_0x54eef1[_0x573f('0x29')]);if(_0x54eef1[_0x573f('0x2a')]){delete _0x54eef1[_0x573f('0x2a')];}_0x253e2c['status'](_0x343296)['send'](_0x54eef1);};}exports[_0x573f('0x2b')]=function(_0x3eb44a,_0x1b2582){var _0x164a4e={},_0x30c1b4={},_0x17ba36={'count':0x0,'rows':[]};var _0x1a43a2=_[_0x573f('0x2c')](db['JscriptyProject'][_0x573f('0x2d')],function(_0x2169aa){return{'name':_0x2169aa[_0x573f('0x2e')],'type':_0x2169aa[_0x573f('0x2f')][_0x573f('0x30')]};});_0x30c1b4['model']=_[_0x573f('0x2c')](_0x1a43a2,_0x573f('0x2a'));_0x30c1b4[_0x573f('0x31')]=_['keys'](_0x3eb44a[_0x573f('0x31')]);_0x30c1b4[_0x573f('0x32')]=_[_0x573f('0x33')](_0x30c1b4['model'],_0x30c1b4[_0x573f('0x31')]);_0x164a4e[_0x573f('0x34')]=_[_0x573f('0x33')](_0x30c1b4['model'],qs['fields'](_0x3eb44a['query'][_0x573f('0x35')]));_0x164a4e['attributes']=_0x164a4e[_0x573f('0x34')]['length']?_0x164a4e[_0x573f('0x34')]:_0x30c1b4['model'];if(!_0x3eb44a[_0x573f('0x31')][_0x573f('0x36')](_0x573f('0x37'))){_0x164a4e[_0x573f('0x1a')]=qs[_0x573f('0x1a')](_0x3eb44a[_0x573f('0x31')][_0x573f('0x1a')]);_0x164a4e[_0x573f('0x18')]=qs[_0x573f('0x18')](_0x3eb44a[_0x573f('0x31')][_0x573f('0x18')]);}_0x164a4e['order']=qs[_0x573f('0x38')](_0x3eb44a[_0x573f('0x31')]['sort']);_0x164a4e[_0x573f('0x39')]=qs[_0x573f('0x32')](_[_0x573f('0x3a')](_0x3eb44a[_0x573f('0x31')],_0x30c1b4['filters']),_0x1a43a2);if(_0x3eb44a[_0x573f('0x31')][_0x573f('0x3b')]){_0x164a4e[_0x573f('0x39')]=_[_0x573f('0x3c')](_0x164a4e['where'],{'$or':_['map'](_0x1a43a2,function(_0x29e5a4){if(_0x29e5a4[_0x573f('0x2f')]!==_0x573f('0x3d')){var _0x52d508={};_0x52d508[_0x29e5a4[_0x573f('0x2a')]]={'$like':'%'+_0x3eb44a[_0x573f('0x31')][_0x573f('0x3b')]+'%'};return _0x52d508;}})});}_0x164a4e=_[_0x573f('0x3c')]({},_0x164a4e,_0x3eb44a[_0x573f('0x3e')]);var _0x2b3419={'where':_0x164a4e[_0x573f('0x39')]};return db[_0x573f('0x3f')][_0x573f('0x1b')](_0x2b3419)['then'](function(_0x427126){_0x17ba36['count']=_0x427126;if(_0x3eb44a[_0x573f('0x31')][_0x573f('0x40')]){_0x164a4e[_0x573f('0x41')]=[{'all':!![]}];}return db[_0x573f('0x3f')]['findAll'](_0x164a4e);})['then'](function(_0x2660dc){_0x17ba36[_0x573f('0x42')]=_0x2660dc;return _0x17ba36;})['then'](respondWithFilteredResult(_0x1b2582,_0x164a4e))[_0x573f('0x43')](handleError(_0x1b2582,null));};exports[_0x573f('0x44')]=function(_0xff317f,_0x7537c){var _0xc755c4={'raw':![],'where':{'id':_0xff317f[_0x573f('0x45')]['id']}},_0x38ee04={};_0x38ee04[_0x573f('0x46')]=_[_0x573f('0x47')](db[_0x573f('0x3f')][_0x573f('0x2d')]);_0x38ee04['query']=_[_0x573f('0x47')](_0xff317f['query']);_0x38ee04[_0x573f('0x32')]=_['intersection'](_0x38ee04[_0x573f('0x46')],_0x38ee04['query']);_0xc755c4[_0x573f('0x34')]=_[_0x573f('0x33')](_0x38ee04[_0x573f('0x46')],qs['fields'](_0xff317f[_0x573f('0x31')][_0x573f('0x35')]));_0xc755c4[_0x573f('0x34')]=_0xc755c4[_0x573f('0x34')][_0x573f('0x48')]?_0xc755c4[_0x573f('0x34')]:_0x38ee04[_0x573f('0x46')];if(_0xff317f[_0x573f('0x31')][_0x573f('0x40')]){_0xc755c4[_0x573f('0x41')]=[{'all':!![]}];}_0xc755c4=_['merge']({},_0xc755c4,_0xff317f[_0x573f('0x3e')]);return db[_0x573f('0x3f')]['find'](_0xc755c4)['then'](handleEntityNotFound(_0x7537c,null))['then'](respondWithResult(_0x7537c,null))['catch'](handleError(_0x7537c,null));};exports[_0x573f('0x49')]=function(_0x2ccde3,_0x354a83){return db[_0x573f('0x3f')][_0x573f('0x49')](_0x2ccde3['body'],{})['then'](function(_0x5ccbf9){var _0xbf5d44=_0x2ccde3[_0x573f('0x4a')]['get']({'plain':!![]});if(!_0xbf5d44)throw new Error(_0x573f('0x4b'));if(_0xbf5d44[_0x573f('0x4c')]==='user'){var _0x5d2d97=_0x5ccbf9[_0x573f('0x4d')]({'plain':!![]});var _0x4d2ceb=_0x573f('0x25');return db[_0x573f('0x4e')][_0x573f('0x4f')]({'where':{'name':_0x4d2ceb,'userProfileId':_0xbf5d44[_0x573f('0x50')]},'raw':!![]})['then'](function(_0x2851e2){if(_0x2851e2&&_0x2851e2['autoAssociation']===0x0){return db[_0x573f('0x26')]['create']({'name':_0x5d2d97[_0x573f('0x2a')],'resourceId':_0x5d2d97['id'],'type':_0x2851e2[_0x573f('0x2a')],'sectionId':_0x2851e2['id']},{})[_0x573f('0x23')](function(){return _0x5ccbf9;});}else{return _0x5ccbf9;}})['catch'](function(_0x3ffb02){logger[_0x573f('0x28')](_0x573f('0x51'),_0x3ffb02);throw _0x3ffb02;});}return _0x5ccbf9;})['then'](respondWithResult(_0x354a83,0xc9))['catch'](handleError(_0x354a83,null));};exports[_0x573f('0x52')]=function(_0x35cea3,_0x3a70b1){var _0x1e8162={'where':{'id':_0x35cea3[_0x573f('0x45')]['id']}},_0x1d7c2a={};_0x1d7c2a[_0x573f('0x46')]=_[_0x573f('0x47')](db[_0x573f('0x3f')]['rawAttributes']);_0x1e8162['attributes']=_['intersection'](_0x1d7c2a[_0x573f('0x46')],qs[_0x573f('0x35')](_0x35cea3['query'][_0x573f('0x35')]));_0x1e8162[_0x573f('0x34')]=_0x1e8162[_0x573f('0x34')]['length']?_0x1e8162['attributes']:_0x1d7c2a['model'];if(_0x35cea3[_0x573f('0x31')][_0x573f('0x40')]){_0x1e8162[_0x573f('0x41')]=[{'all':!![]}];}_0x1e8162=_['merge']({},_0x1e8162,_0x35cea3[_0x573f('0x3e')]);return db[_0x573f('0x3f')]['find'](_0x1e8162)[_0x573f('0x23')](handleEntityNotFound(_0x3a70b1,null))[_0x573f('0x23')](function(_0x3da2d6){if(_0x3da2d6){var _0x78b369=_0x3da2d6[_0x573f('0x4d')]({'plain':!![]});_0x78b369=qs[_0x573f('0x53')](_0x78b369,['id',_0x573f('0x54'),_0x573f('0x55')]);_0x35cea3['body']=_[_0x573f('0x53')](_0x35cea3[_0x573f('0x56')],['id',_0x573f('0x54'),_0x573f('0x55')]);return db['JscriptyProject'][_0x573f('0x49')](_[_0x573f('0x3c')](_0x78b369,_0x35cea3[_0x573f('0x56')]),{'include':_0x35cea3['query'][_0x573f('0x40')]?[{'all':!![]}]:undefined})[_0x573f('0x23')](function(_0x24bab6){var _0x298ca8=_0x35cea3[_0x573f('0x4a')]['get']({'plain':!![]});if(!_0x298ca8)throw new Error(_0x573f('0x4b'));if(_0x298ca8[_0x573f('0x4c')]===_0x573f('0x4a')){var _0x52b8f8=_0x24bab6[_0x573f('0x4d')]({'plain':!![]});var _0x17192b=_0x573f('0x25');return db[_0x573f('0x4e')][_0x573f('0x4f')]({'where':{'name':_0x17192b,'userProfileId':_0x298ca8[_0x573f('0x50')]},'raw':!![]})[_0x573f('0x23')](function(_0x17c120){if(_0x17c120&&_0x17c120[_0x573f('0x57')]===0x0){return db[_0x573f('0x26')][_0x573f('0x49')]({'name':_0x52b8f8[_0x573f('0x2a')],'resourceId':_0x52b8f8['id'],'type':_0x17c120['name'],'sectionId':_0x17c120['id']},{})[_0x573f('0x23')](function(){return _0x24bab6;});}else{return _0x24bab6;}})[_0x573f('0x43')](function(_0x481a78){logger[_0x573f('0x28')](_0x573f('0x51'),_0x481a78);throw _0x481a78;});}return _0x24bab6;});}})[_0x573f('0x23')](respondWithResult(_0x3a70b1,0xc9))['catch'](handleError(_0x3a70b1,null));};exports['update']=function(_0xa94d6a,_0x479e91){if(_0xa94d6a[_0x573f('0x56')]['id']){delete _0xa94d6a[_0x573f('0x56')]['id'];}return db[_0x573f('0x3f')][_0x573f('0x4f')]({'where':{'id':_0xa94d6a[_0x573f('0x45')]['id']}})[_0x573f('0x23')](handleEntityNotFound(_0x479e91,null))[_0x573f('0x23')](saveUpdates(_0xa94d6a[_0x573f('0x56')],null))[_0x573f('0x23')](respondWithResult(_0x479e91,null))[_0x573f('0x43')](handleError(_0x479e91,null));};exports[_0x573f('0x24')]=function(_0x56510d,_0x29f6cf){return db[_0x573f('0x3f')]['find']({'where':{'id':_0x56510d[_0x573f('0x45')]['id']}})['then'](handleEntityNotFound(_0x29f6cf,null))[_0x573f('0x23')](removeEntity(_0x29f6cf,null))[_0x573f('0x43')](handleError(_0x29f6cf,null));};exports['getSessions']=function(_0x1b79c3,_0x3d0895,_0x165c06){var _0x563c07={'raw':!![],'where':{}};var _0x490af5={};var _0x5e78c7={'count':0x0,'rows':[]};return db['JscriptyProject'][_0x573f('0x58')]({'where':{'id':_0x1b79c3[_0x573f('0x45')]['id']}})['then'](handleEntityNotFound(_0x3d0895,null))[_0x573f('0x23')](function(_0x3bb905){if(_0x3bb905){_0x490af5[_0x573f('0x46')]=_[_0x573f('0x47')](db[_0x573f('0x59')][_0x573f('0x2d')]);_0x490af5['query']=_['keys'](_0x1b79c3[_0x573f('0x31')]);_0x490af5['filters']=_[_0x573f('0x33')](_0x490af5[_0x573f('0x46')],_0x490af5[_0x573f('0x31')]);_0x563c07[_0x573f('0x34')]=_[_0x573f('0x33')](_0x490af5[_0x573f('0x46')],qs[_0x573f('0x35')](_0x1b79c3[_0x573f('0x31')]['fields']));_0x563c07[_0x573f('0x34')]=_0x563c07[_0x573f('0x34')][_0x573f('0x48')]?_0x563c07['attributes']:_0x490af5[_0x573f('0x46')];if(!_0x1b79c3[_0x573f('0x31')]['hasOwnProperty'](_0x573f('0x37'))){_0x563c07[_0x573f('0x1a')]=qs[_0x573f('0x1a')](_0x1b79c3[_0x573f('0x31')]['limit']);_0x563c07[_0x573f('0x18')]=qs[_0x573f('0x18')](_0x1b79c3[_0x573f('0x31')][_0x573f('0x18')]);}_0x563c07['order']=qs[_0x573f('0x38')](_0x1b79c3[_0x573f('0x31')][_0x573f('0x38')]);_0x563c07['where']=qs[_0x573f('0x32')](_['pick'](_0x1b79c3['query'],_0x490af5['filters']));_0x563c07[_0x573f('0x39')][_0x573f('0x5a')]=_0x3bb905['id'];if(_0x1b79c3[_0x573f('0x31')][_0x573f('0x3b')]){_0x563c07[_0x573f('0x39')]=_[_0x573f('0x3c')](_0x563c07[_0x573f('0x39')],{'$or':_[_0x573f('0x2c')](_0x563c07[_0x573f('0x34')],function(_0x36008){var _0x2f79ac={};_0x2f79ac[_0x36008]={'$like':'%'+_0x1b79c3[_0x573f('0x31')][_0x573f('0x3b')]+'%'};return _0x2f79ac;})});}_0x563c07=_['merge']({},_0x563c07,_0x1b79c3[_0x573f('0x3e')]);return db[_0x573f('0x59')]['count']({'where':_0x563c07['where']})[_0x573f('0x23')](function(_0x370837){_0x5e78c7[_0x573f('0x1b')]=_0x370837;if(_0x1b79c3[_0x573f('0x31')]['includeAll']){_0x563c07['include']=[{'all':!![]}];}return db[_0x573f('0x59')]['findAll'](_0x563c07);})[_0x573f('0x23')](function(_0x3918c6){_0x5e78c7[_0x573f('0x42')]=_0x3918c6;return _0x5e78c7;});}})[_0x573f('0x23')](respondWithFilteredResult(_0x3d0895,_0x563c07))['catch'](handleError(_0x3d0895,null));};exports[_0x573f('0x5b')]=function(_0x2dd5ea,_0x536f8c,_0x464d41){var _0x290511={'raw':!![],'where':{}};var _0x4121b5={};var _0x5af3da={'count':0x0,'rows':[]};return db[_0x573f('0x3f')][_0x573f('0x58')]({'where':{'id':_0x2dd5ea[_0x573f('0x45')]['id']}})[_0x573f('0x23')](handleEntityNotFound(_0x536f8c,null))[_0x573f('0x23')](function(_0x126d7d){if(_0x126d7d){_0x4121b5[_0x573f('0x46')]=_[_0x573f('0x47')](db[_0x573f('0x5c')][_0x573f('0x2d')]);_0x4121b5[_0x573f('0x31')]=_[_0x573f('0x47')](_0x2dd5ea[_0x573f('0x31')]);_0x4121b5[_0x573f('0x32')]=_[_0x573f('0x33')](_0x4121b5[_0x573f('0x46')],_0x4121b5['query']);_0x290511[_0x573f('0x34')]=_['intersection'](_0x4121b5[_0x573f('0x46')],qs[_0x573f('0x35')](_0x2dd5ea[_0x573f('0x31')]['fields']));_0x290511[_0x573f('0x34')]=_0x290511[_0x573f('0x34')][_0x573f('0x48')]?_0x290511[_0x573f('0x34')]:_0x4121b5[_0x573f('0x46')];if(!_0x2dd5ea['query']['hasOwnProperty']('nolimit')){_0x290511[_0x573f('0x1a')]=qs['limit'](_0x2dd5ea[_0x573f('0x31')][_0x573f('0x1a')]);_0x290511[_0x573f('0x18')]=qs['offset'](_0x2dd5ea[_0x573f('0x31')][_0x573f('0x18')]);}_0x290511[_0x573f('0x5d')]=qs[_0x573f('0x38')](_0x2dd5ea[_0x573f('0x31')][_0x573f('0x38')]);_0x290511[_0x573f('0x39')]=qs['filters'](_[_0x573f('0x3a')](_0x2dd5ea[_0x573f('0x31')],_0x4121b5[_0x573f('0x32')]));_0x290511['where'][_0x573f('0x5a')]=_0x126d7d['id'];if(_0x2dd5ea[_0x573f('0x31')][_0x573f('0x3b')]){_0x290511[_0x573f('0x39')]=_[_0x573f('0x3c')](_0x290511['where'],{'$or':_['map'](_0x290511[_0x573f('0x34')],function(_0x3724a0){var _0x37915e={};_0x37915e[_0x3724a0]={'$like':'%'+_0x2dd5ea[_0x573f('0x31')]['filter']+'%'};return _0x37915e;})});}_0x290511=_[_0x573f('0x3c')]({},_0x290511,_0x2dd5ea[_0x573f('0x3e')]);return db['JscriptyAnswerReport'][_0x573f('0x1b')]({'where':_0x290511['where']})[_0x573f('0x23')](function(_0x58010e){_0x5af3da['count']=_0x58010e;if(_0x2dd5ea[_0x573f('0x31')][_0x573f('0x40')]){_0x290511['include']=[{'all':!![]}];}return db[_0x573f('0x5c')][_0x573f('0x5e')](_0x290511);})[_0x573f('0x23')](function(_0x134a12){_0x5af3da[_0x573f('0x42')]=_0x134a12;return _0x5af3da;});}})[_0x573f('0x23')](respondWithFilteredResult(_0x536f8c,_0x290511))[_0x573f('0x43')](handleError(_0x536f8c,null));};function char(_0x2f14fa){return _0x573f('0x5f')===typeof _0x2f14fa?String['fromCharCode'][_0x573f('0x1f')](null,arguments):_0x2f14fa;}function needsEncapsulation(_0x3c4326){return!!_0x3c4326&&(_0x3c4326[_0x573f('0x60')]()[_0x573f('0x61')](char(0xd))>=0x0||_0x3c4326[_0x573f('0x60')]()[_0x573f('0x61')](char(0xa))>=0x0||_0x3c4326[_0x573f('0x60')]()[_0x573f('0x61')](char(0x2c))>=0x0||_0x3c4326[_0x573f('0x60')]()['indexOf'](char(0x22))>=0x0);}function encapsulate(_0x4a53fa){var _0x23c51b=char(0x22),_0x3bfb8a='\x5c'+char(0x22),_0x450de8=_0x4a53fa[_0x573f('0x60')]()[_0x573f('0x62')](new RegExp(_0x23c51b,'g'),_0x3bfb8a);return _0x23c51b+_0x450de8+_0x23c51b;}exports[_0x573f('0x63')]=function(_0x11ae8f,_0x3678b4,_0x19186b){var _0x2afa6a,_0x2d5f6c;var _0x36fa54={'where':{'ProjectId':_0x11ae8f['params']['id']}};if(_0x11ae8f[_0x573f('0x31')]['startTime']){_0x36fa54['where'][_0x573f('0x64')]=JSON[_0x573f('0x65')](_0x11ae8f['query'][_0x573f('0x66')]);}return db[_0x573f('0x59')][_0x573f('0x5e')](_0x36fa54)[_0x573f('0x23')](handleEntityNotFound(_0x3678b4,null))['then'](function(_0x401167){if(_0x401167){_0x2afa6a=_0x401167;return db['JscriptyQuestionReport'][_0x573f('0x5e')]({'where':{'SessionId':{'$in':_[_0x573f('0x2c')](_0x2afa6a,'id')},'ProjectId':_0x11ae8f[_0x573f('0x45')]['id']},'order':_0x573f('0x67')});}})[_0x573f('0x23')](handleEntityNotFound(_0x3678b4,null))['then'](function(_0x37c282){if(_0x37c282){_0x2d5f6c=_0x37c282;var _0x2751fc={};for(var _0x40bc50=0x0,_0x4b6092=_0x2d5f6c[_0x573f('0x48')];_0x40bc50<_0x4b6092;_0x40bc50++){if(!_0x2751fc[_0x573f('0x36')](_0x2d5f6c[_0x40bc50][_0x573f('0x68')])){_0x2751fc[_0x2d5f6c[_0x40bc50][_0x573f('0x68')]]=needsEncapsulation(_0x2d5f6c[_0x40bc50][_0x573f('0x69')])?encapsulate(_0x2d5f6c[_0x40bc50][_0x573f('0x69')]):_0x2d5f6c[_0x40bc50][_0x573f('0x69')];}}var _0x163d96=[],_0x3c3cf2={};for(var _0x386864=0x0,_0x27cc4c=_0x2afa6a[_0x573f('0x48')];_0x386864<_0x27cc4c;_0x386864++){_0x3c3cf2={'ProjectId':_0x11ae8f[_0x573f('0x45')]['id'],'SessionId':_0x2afa6a[_0x386864]['id'],'StartTime':moment(_0x2afa6a[_0x386864][_0x573f('0x64')])['format'](_0x573f('0x6a'))};for(var _0x1c0e8a=0x0,_0x1cedd8=_0x2d5f6c[_0x573f('0x48')];_0x1c0e8a<_0x1cedd8;_0x1c0e8a++){if(_0x2d5f6c[_0x1c0e8a][_0x573f('0x6b')]==_0x2afa6a[_0x386864]['id']&&_0x2751fc[_0x573f('0x36')](_0x2d5f6c[_0x1c0e8a]['questionId'])){_0x3c3cf2[_0x2751fc[_0x2d5f6c[_0x1c0e8a][_0x573f('0x68')]]]=_0x2d5f6c[_0x1c0e8a][_0x573f('0x6c')];}}for(var _0x32b05c in _0x2751fc){if(!_0x3c3cf2['hasOwnProperty'](_0x2751fc[_0x32b05c])){_0x3c3cf2[_0x2751fc[_0x32b05c]]=null;}}_0x163d96['push'](_0x3c3cf2);}return _0x163d96;}})[_0x573f('0x23')](function(_0x4f0061){if(!_[_0x573f('0x6d')](_0x4f0061)){var _0x2ff370=toCsv(_0x4f0061);var _0x3d9eaf=Date[_0x573f('0x6e')]();fs[_0x573f('0x6f')](util[_0x573f('0x70')](_0x573f('0x71'),_0x11ae8f['params']['id'],_0x3d9eaf),_0x2ff370);_0x3678b4[_0x573f('0x72')](_0x573f('0x73'),_0x573f('0x74')+util[_0x573f('0x70')](_0x573f('0x75'),_0x11ae8f[_0x573f('0x45')]['id'],_0x3d9eaf));_0x3678b4[_0x573f('0x72')](_0x573f('0x76'),_0x573f('0x77'));return _0x3678b4[_0x573f('0x78')](util[_0x573f('0x70')]('/tmp/Jscripty_Project_%d_Summary_%s.csv',_0x11ae8f[_0x573f('0x45')]['id'],_0x3d9eaf));}else{return _0x3678b4[_0x573f('0x16')](0xcc);}})[_0x573f('0x43')](handleError(_0x3678b4,null));};
\ No newline at end of file