Built motion from commit 3c2ce842.|2.6.31
[motion2.git] / server / api / jscriptyProject / jscriptyProject.controller.js
index a41122a..ff4fa02 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x17ba=['where','merge','options','then','findAll','rows','catch','show','length','includeAll','include','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','omit','createdAt','updatedAt','getSessions','findOne','JscriptySessionReport','order','pick','ProjectId','getAnswers','JscriptyAnswerReport','number','fromCharCode','toString','indexOf','startTime','starttime','JscriptyQuestionReport','questionId','question','format','answer','push','now','writeFileSync','setHeader','attachment;\x20filename=','Content-type','download','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','count','set','Content-Range','apply','reject','save','update','get','Projects','UserProfileResource','destroy','error','stack','name','send','index','map','JscriptyProject','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','sort','filter'];(function(_0x2d16a9,_0x3d29cb){var _0x235bf8=function(_0x41feaa){while(--_0x41feaa){_0x2d16a9['push'](_0x2d16a9['shift']());}};_0x235bf8(++_0x3d29cb);}(_0x17ba,0xab));var _0xa17b=function(_0x284b8a,_0x566705){_0x284b8a=_0x284b8a-0x0;var _0x495caf=_0x17ba[_0x284b8a];return _0x495caf;};'use strict';var emlformat=require(_0xa17b('0x0'));var rimraf=require(_0xa17b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xa17b('0x2'));var rp=require(_0xa17b('0x3'));var moment=require(_0xa17b('0x4'));var BPromise=require(_0xa17b('0x5'));var Mustache=require(_0xa17b('0x6'));var util=require(_0xa17b('0x7'));var path=require(_0xa17b('0x8'));var sox=require(_0xa17b('0x9'));var csv=require(_0xa17b('0xa'));var ejs=require(_0xa17b('0xb'));var fs=require('fs');var fs_extra=require(_0xa17b('0xc'));var _=require(_0xa17b('0xd'));var squel=require(_0xa17b('0xe'));var crypto=require(_0xa17b('0xf'));var jsforce=require(_0xa17b('0x10'));var deskjs=require(_0xa17b('0x11'));var toCsv=require(_0xa17b('0xa'));var querystring=require(_0xa17b('0x12'));var Papa=require(_0xa17b('0x13'));var Redis=require('ioredis');var authService=require(_0xa17b('0x14'));var qs=require(_0xa17b('0x15'));var as=require(_0xa17b('0x16'));var hardwareService=require(_0xa17b('0x17'));var logger=require(_0xa17b('0x18'))(_0xa17b('0x19'));var utils=require(_0xa17b('0x1a'));var config=require('../../config/environment');var licenseUtil=require(_0xa17b('0x1b'));var db=require(_0xa17b('0x1c'))['db'];function respondWithStatusCode(_0x3c3a8a,_0x52b7aa){_0x52b7aa=_0x52b7aa||0xcc;return function(_0x3abc59){if(_0x3abc59){return _0x3c3a8a[_0xa17b('0x1d')](_0x52b7aa);}return _0x3c3a8a[_0xa17b('0x1e')](_0x52b7aa)[_0xa17b('0x1f')]();};}function respondWithResult(_0x4a222e,_0x117ad9){_0x117ad9=_0x117ad9||0xc8;return function(_0x529910){if(_0x529910){return _0x4a222e[_0xa17b('0x1e')](_0x117ad9)[_0xa17b('0x20')](_0x529910);}};}function respondWithFilteredResult(_0x5de138,_0x112764){return function(_0x3c63e3){if(_0x3c63e3){var _0x1c0578=typeof _0x112764[_0xa17b('0x21')]==='undefined'&&typeof _0x112764[_0xa17b('0x22')]==='undefined';var _0x4d5592=_0x3c63e3['count'];var _0x36f985=_0x1c0578?0x0:_0x112764[_0xa17b('0x21')];var _0x53a0f7=_0x1c0578?_0x3c63e3[_0xa17b('0x23')]:_0x112764[_0xa17b('0x21')]+_0x112764[_0xa17b('0x22')];var _0x2fb679;if(_0x53a0f7>=_0x4d5592){_0x53a0f7=_0x4d5592;_0x2fb679=0xc8;}else{_0x2fb679=0xce;}_0x5de138[_0xa17b('0x1e')](_0x2fb679);return _0x5de138[_0xa17b('0x24')](_0xa17b('0x25'),_0x36f985+'-'+_0x53a0f7+'/'+_0x4d5592)['json'](_0x3c63e3);}return null;};}function patchUpdates(_0x610c2b){return function(_0x3f409a){try{jsonpatch[_0xa17b('0x26')](_0x3f409a,_0x610c2b,!![]);}catch(_0x52e75a){return BPromise[_0xa17b('0x27')](_0x52e75a);}return _0x3f409a[_0xa17b('0x28')]();};}function saveUpdates(_0x24d305,_0xbbbb62){return function(_0x3c7ec2){if(_0x3c7ec2){return _0x3c7ec2[_0xa17b('0x29')](_0x24d305)['then'](function(_0x3df11f){return _0x3df11f;});}return null;};}function removeEntity(_0x4d4a65,_0xa34739){return function(_0x13630d){if(_0x13630d){return _0x13630d['destroy']()['then'](function(){var _0x2a298c=_0x13630d[_0xa17b('0x2a')]({'plain':!![]});var _0x4216ca=_0xa17b('0x2b');return db[_0xa17b('0x2c')][_0xa17b('0x2d')]({'where':{'type':_0x4216ca,'resourceId':_0x2a298c['id']}})['then'](function(){return _0x13630d;});})['then'](function(){_0x4d4a65['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x2b1708,_0x5ef356){return function(_0x295e67){if(!_0x295e67){_0x2b1708['sendStatus'](0x194);}return _0x295e67;};}function handleError(_0x14671b,_0x3b2ba6){_0x3b2ba6=_0x3b2ba6||0x1f4;return function(_0x32cad9){logger[_0xa17b('0x2e')](_0x32cad9[_0xa17b('0x2f')]);if(_0x32cad9[_0xa17b('0x30')]){delete _0x32cad9[_0xa17b('0x30')];}_0x14671b[_0xa17b('0x1e')](_0x3b2ba6)[_0xa17b('0x31')](_0x32cad9);};}exports[_0xa17b('0x32')]=function(_0xe84db5,_0x573585){var _0x57a2c4={},_0x58d7b6={},_0x404369={'count':0x0,'rows':[]};var _0x11070a=_[_0xa17b('0x33')](db[_0xa17b('0x34')][_0xa17b('0x35')],function(_0x156409){return{'name':_0x156409[_0xa17b('0x36')],'type':_0x156409[_0xa17b('0x37')]['key']};});_0x58d7b6[_0xa17b('0x38')]=_['map'](_0x11070a,_0xa17b('0x30'));_0x58d7b6[_0xa17b('0x39')]=_[_0xa17b('0x3a')](_0xe84db5[_0xa17b('0x39')]);_0x58d7b6[_0xa17b('0x3b')]=_[_0xa17b('0x3c')](_0x58d7b6['model'],_0x58d7b6[_0xa17b('0x39')]);_0x57a2c4[_0xa17b('0x3d')]=_[_0xa17b('0x3c')](_0x58d7b6[_0xa17b('0x38')],qs[_0xa17b('0x3e')](_0xe84db5['query'][_0xa17b('0x3e')]));_0x57a2c4['attributes']=_0x57a2c4[_0xa17b('0x3d')]['length']?_0x57a2c4[_0xa17b('0x3d')]:_0x58d7b6[_0xa17b('0x38')];if(!_0xe84db5['query'][_0xa17b('0x3f')](_0xa17b('0x40'))){_0x57a2c4['limit']=qs[_0xa17b('0x22')](_0xe84db5[_0xa17b('0x39')][_0xa17b('0x22')]);_0x57a2c4[_0xa17b('0x21')]=qs[_0xa17b('0x21')](_0xe84db5['query'][_0xa17b('0x21')]);}_0x57a2c4['order']=qs[_0xa17b('0x41')](_0xe84db5['query'][_0xa17b('0x41')]);_0x57a2c4['where']=qs[_0xa17b('0x3b')](_['pick'](_0xe84db5[_0xa17b('0x39')],_0x58d7b6['filters']),_0x11070a);if(_0xe84db5[_0xa17b('0x39')][_0xa17b('0x42')]){_0x57a2c4[_0xa17b('0x43')]=_[_0xa17b('0x44')](_0x57a2c4[_0xa17b('0x43')],{'$or':_[_0xa17b('0x33')](_0x11070a,function(_0xc4bb53){if(_0xc4bb53[_0xa17b('0x37')]!=='VIRTUAL'){var _0x468c92={};_0x468c92[_0xc4bb53[_0xa17b('0x30')]]={'$like':'%'+_0xe84db5['query'][_0xa17b('0x42')]+'%'};return _0x468c92;}})});}_0x57a2c4=_[_0xa17b('0x44')]({},_0x57a2c4,_0xe84db5[_0xa17b('0x45')]);var _0x318b3e={'where':_0x57a2c4[_0xa17b('0x43')]};return db[_0xa17b('0x34')]['count'](_0x318b3e)[_0xa17b('0x46')](function(_0x1521fe){_0x404369[_0xa17b('0x23')]=_0x1521fe;if(_0xe84db5['query']['includeAll']){_0x57a2c4['include']=[{'all':!![]}];}return db[_0xa17b('0x34')][_0xa17b('0x47')](_0x57a2c4);})[_0xa17b('0x46')](function(_0x1d6b35){_0x404369[_0xa17b('0x48')]=_0x1d6b35;return _0x404369;})[_0xa17b('0x46')](respondWithFilteredResult(_0x573585,_0x57a2c4))[_0xa17b('0x49')](handleError(_0x573585,null));};exports[_0xa17b('0x4a')]=function(_0x1704ba,_0x24f0de){var _0x1dda63={'raw':![],'where':{'id':_0x1704ba['params']['id']}},_0x1267de={};_0x1267de[_0xa17b('0x38')]=_[_0xa17b('0x3a')](db[_0xa17b('0x34')][_0xa17b('0x35')]);_0x1267de[_0xa17b('0x39')]=_[_0xa17b('0x3a')](_0x1704ba['query']);_0x1267de[_0xa17b('0x3b')]=_[_0xa17b('0x3c')](_0x1267de[_0xa17b('0x38')],_0x1267de[_0xa17b('0x39')]);_0x1dda63[_0xa17b('0x3d')]=_['intersection'](_0x1267de[_0xa17b('0x38')],qs[_0xa17b('0x3e')](_0x1704ba[_0xa17b('0x39')][_0xa17b('0x3e')]));_0x1dda63['attributes']=_0x1dda63[_0xa17b('0x3d')][_0xa17b('0x4b')]?_0x1dda63[_0xa17b('0x3d')]:_0x1267de[_0xa17b('0x38')];if(_0x1704ba[_0xa17b('0x39')][_0xa17b('0x4c')]){_0x1dda63[_0xa17b('0x4d')]=[{'all':!![]}];}_0x1dda63=_['merge']({},_0x1dda63,_0x1704ba[_0xa17b('0x45')]);return db[_0xa17b('0x34')]['find'](_0x1dda63)[_0xa17b('0x46')](handleEntityNotFound(_0x24f0de,null))[_0xa17b('0x46')](respondWithResult(_0x24f0de,null))[_0xa17b('0x49')](handleError(_0x24f0de,null));};exports['create']=function(_0x187237,_0x4681ca){return db['JscriptyProject'][_0xa17b('0x4e')](_0x187237[_0xa17b('0x4f')],{})['then'](function(_0x2950ee){var _0x347436=_0x187237['user'][_0xa17b('0x2a')]({'plain':!![]});if(!_0x347436)throw new Error(_0xa17b('0x50'));if(_0x347436[_0xa17b('0x51')]===_0xa17b('0x52')){var _0x2f4a2c=_0x2950ee[_0xa17b('0x2a')]({'plain':!![]});var _0x32e7ce='Projects';return db[_0xa17b('0x53')][_0xa17b('0x54')]({'where':{'name':_0x32e7ce,'userProfileId':_0x347436[_0xa17b('0x55')]},'raw':!![]})[_0xa17b('0x46')](function(_0x13b3af){if(_0x13b3af&&_0x13b3af[_0xa17b('0x56')]===0x0){return db[_0xa17b('0x2c')][_0xa17b('0x4e')]({'name':_0x2f4a2c[_0xa17b('0x30')],'resourceId':_0x2f4a2c['id'],'type':_0x13b3af[_0xa17b('0x30')],'sectionId':_0x13b3af['id']},{})[_0xa17b('0x46')](function(){return _0x2950ee;});}else{return _0x2950ee;}})[_0xa17b('0x49')](function(_0x40abbf){logger['error'](_0xa17b('0x57'),_0x40abbf);throw _0x40abbf;});}return _0x2950ee;})[_0xa17b('0x46')](respondWithResult(_0x4681ca,0xc9))[_0xa17b('0x49')](handleError(_0x4681ca,null));};exports[_0xa17b('0x58')]=function(_0x43b54f,_0x134c44){var _0x13069e={'where':{'id':_0x43b54f[_0xa17b('0x59')]['id']}},_0x27cb67={};_0x27cb67['model']=_['keys'](db[_0xa17b('0x34')][_0xa17b('0x35')]);_0x13069e['attributes']=_['intersection'](_0x27cb67['model'],qs[_0xa17b('0x3e')](_0x43b54f[_0xa17b('0x39')][_0xa17b('0x3e')]));_0x13069e[_0xa17b('0x3d')]=_0x13069e[_0xa17b('0x3d')][_0xa17b('0x4b')]?_0x13069e['attributes']:_0x27cb67['model'];if(_0x43b54f['query']['includeAll']){_0x13069e['include']=[{'all':!![]}];}_0x13069e=_[_0xa17b('0x44')]({},_0x13069e,_0x43b54f[_0xa17b('0x45')]);return db[_0xa17b('0x34')][_0xa17b('0x54')](_0x13069e)[_0xa17b('0x46')](handleEntityNotFound(_0x134c44,null))[_0xa17b('0x46')](function(_0x3270a0){if(_0x3270a0){var _0x55b98a=_0x3270a0[_0xa17b('0x2a')]({'plain':!![]});_0x55b98a=qs[_0xa17b('0x5a')](_0x55b98a,['id',_0xa17b('0x5b'),_0xa17b('0x5c')]);_0x43b54f[_0xa17b('0x4f')]=_[_0xa17b('0x5a')](_0x43b54f[_0xa17b('0x4f')],['id',_0xa17b('0x5b'),_0xa17b('0x5c')]);return db[_0xa17b('0x34')][_0xa17b('0x4e')](_[_0xa17b('0x44')](_0x55b98a,_0x43b54f['body']),{'include':_0x43b54f[_0xa17b('0x39')]['includeAll']?[{'all':!![]}]:undefined})[_0xa17b('0x46')](function(_0x290e04){var _0x203eee=_0x43b54f[_0xa17b('0x52')]['get']({'plain':!![]});if(!_0x203eee)throw new Error(_0xa17b('0x50'));if(_0x203eee['role']===_0xa17b('0x52')){var _0x5a94a9=_0x290e04['get']({'plain':!![]});var _0x299c83=_0xa17b('0x2b');return db['UserProfileSection'][_0xa17b('0x54')]({'where':{'name':_0x299c83,'userProfileId':_0x203eee[_0xa17b('0x55')]},'raw':!![]})['then'](function(_0x5e8bd4){if(_0x5e8bd4&&_0x5e8bd4[_0xa17b('0x56')]===0x0){return db[_0xa17b('0x2c')]['create']({'name':_0x5a94a9[_0xa17b('0x30')],'resourceId':_0x5a94a9['id'],'type':_0x5e8bd4[_0xa17b('0x30')],'sectionId':_0x5e8bd4['id']},{})['then'](function(){return _0x290e04;});}else{return _0x290e04;}})[_0xa17b('0x49')](function(_0x3ad933){logger[_0xa17b('0x2e')](_0xa17b('0x57'),_0x3ad933);throw _0x3ad933;});}return _0x290e04;});}})[_0xa17b('0x46')](respondWithResult(_0x134c44,0xc9))['catch'](handleError(_0x134c44,null));};exports[_0xa17b('0x29')]=function(_0x3d4e6a,_0x1367c5){if(_0x3d4e6a[_0xa17b('0x4f')]['id']){delete _0x3d4e6a[_0xa17b('0x4f')]['id'];}return db[_0xa17b('0x34')][_0xa17b('0x54')]({'where':{'id':_0x3d4e6a[_0xa17b('0x59')]['id']}})[_0xa17b('0x46')](handleEntityNotFound(_0x1367c5,null))[_0xa17b('0x46')](saveUpdates(_0x3d4e6a['body'],null))[_0xa17b('0x46')](respondWithResult(_0x1367c5,null))[_0xa17b('0x49')](handleError(_0x1367c5,null));};exports['destroy']=function(_0x5f5964,_0x14dbba){return db[_0xa17b('0x34')][_0xa17b('0x54')]({'where':{'id':_0x5f5964[_0xa17b('0x59')]['id']}})[_0xa17b('0x46')](handleEntityNotFound(_0x14dbba,null))['then'](removeEntity(_0x14dbba,null))[_0xa17b('0x49')](handleError(_0x14dbba,null));};exports[_0xa17b('0x5d')]=function(_0x42e548,_0x4206a6,_0x59e9b0){var _0x29b023={'raw':!![],'where':{}};var _0x4b7980={};var _0x652d41={'count':0x0,'rows':[]};return db[_0xa17b('0x34')][_0xa17b('0x5e')]({'where':{'id':_0x42e548[_0xa17b('0x59')]['id']}})[_0xa17b('0x46')](handleEntityNotFound(_0x4206a6,null))['then'](function(_0x8ec93e){if(_0x8ec93e){_0x4b7980[_0xa17b('0x38')]=_[_0xa17b('0x3a')](db[_0xa17b('0x5f')][_0xa17b('0x35')]);_0x4b7980['query']=_[_0xa17b('0x3a')](_0x42e548[_0xa17b('0x39')]);_0x4b7980['filters']=_[_0xa17b('0x3c')](_0x4b7980[_0xa17b('0x38')],_0x4b7980['query']);_0x29b023['attributes']=_[_0xa17b('0x3c')](_0x4b7980[_0xa17b('0x38')],qs[_0xa17b('0x3e')](_0x42e548['query']['fields']));_0x29b023['attributes']=_0x29b023[_0xa17b('0x3d')]['length']?_0x29b023[_0xa17b('0x3d')]:_0x4b7980[_0xa17b('0x38')];if(!_0x42e548[_0xa17b('0x39')][_0xa17b('0x3f')]('nolimit')){_0x29b023['limit']=qs['limit'](_0x42e548[_0xa17b('0x39')][_0xa17b('0x22')]);_0x29b023[_0xa17b('0x21')]=qs[_0xa17b('0x21')](_0x42e548[_0xa17b('0x39')][_0xa17b('0x21')]);}_0x29b023[_0xa17b('0x60')]=qs[_0xa17b('0x41')](_0x42e548[_0xa17b('0x39')]['sort']);_0x29b023[_0xa17b('0x43')]=qs['filters'](_[_0xa17b('0x61')](_0x42e548['query'],_0x4b7980[_0xa17b('0x3b')]));_0x29b023[_0xa17b('0x43')][_0xa17b('0x62')]=_0x8ec93e['id'];if(_0x42e548['query'][_0xa17b('0x42')]){_0x29b023['where']=_[_0xa17b('0x44')](_0x29b023[_0xa17b('0x43')],{'$or':_[_0xa17b('0x33')](_0x29b023['attributes'],function(_0x27ab81){var _0x166c08={};_0x166c08[_0x27ab81]={'$like':'%'+_0x42e548[_0xa17b('0x39')][_0xa17b('0x42')]+'%'};return _0x166c08;})});}_0x29b023=_[_0xa17b('0x44')]({},_0x29b023,_0x42e548['options']);return db[_0xa17b('0x5f')][_0xa17b('0x23')]({'where':_0x29b023[_0xa17b('0x43')]})[_0xa17b('0x46')](function(_0x2a71e3){_0x652d41['count']=_0x2a71e3;if(_0x42e548[_0xa17b('0x39')][_0xa17b('0x4c')]){_0x29b023[_0xa17b('0x4d')]=[{'all':!![]}];}return db['JscriptySessionReport'][_0xa17b('0x47')](_0x29b023);})[_0xa17b('0x46')](function(_0x407ed8){_0x652d41[_0xa17b('0x48')]=_0x407ed8;return _0x652d41;});}})[_0xa17b('0x46')](respondWithFilteredResult(_0x4206a6,_0x29b023))[_0xa17b('0x49')](handleError(_0x4206a6,null));};exports[_0xa17b('0x63')]=function(_0x5da885,_0x3743a1,_0x2399f2){var _0x5063ad={'raw':!![],'where':{}};var _0x144583={};var _0x5b5bd3={'count':0x0,'rows':[]};return db['JscriptyProject'][_0xa17b('0x5e')]({'where':{'id':_0x5da885[_0xa17b('0x59')]['id']}})[_0xa17b('0x46')](handleEntityNotFound(_0x3743a1,null))['then'](function(_0x26b46b){if(_0x26b46b){_0x144583[_0xa17b('0x38')]=_[_0xa17b('0x3a')](db[_0xa17b('0x64')][_0xa17b('0x35')]);_0x144583[_0xa17b('0x39')]=_[_0xa17b('0x3a')](_0x5da885[_0xa17b('0x39')]);_0x144583['filters']=_['intersection'](_0x144583[_0xa17b('0x38')],_0x144583['query']);_0x5063ad[_0xa17b('0x3d')]=_['intersection'](_0x144583['model'],qs[_0xa17b('0x3e')](_0x5da885['query'][_0xa17b('0x3e')]));_0x5063ad[_0xa17b('0x3d')]=_0x5063ad[_0xa17b('0x3d')][_0xa17b('0x4b')]?_0x5063ad[_0xa17b('0x3d')]:_0x144583[_0xa17b('0x38')];if(!_0x5da885[_0xa17b('0x39')][_0xa17b('0x3f')](_0xa17b('0x40'))){_0x5063ad[_0xa17b('0x22')]=qs[_0xa17b('0x22')](_0x5da885[_0xa17b('0x39')][_0xa17b('0x22')]);_0x5063ad[_0xa17b('0x21')]=qs[_0xa17b('0x21')](_0x5da885[_0xa17b('0x39')]['offset']);}_0x5063ad['order']=qs['sort'](_0x5da885[_0xa17b('0x39')]['sort']);_0x5063ad[_0xa17b('0x43')]=qs[_0xa17b('0x3b')](_['pick'](_0x5da885[_0xa17b('0x39')],_0x144583['filters']));_0x5063ad[_0xa17b('0x43')][_0xa17b('0x62')]=_0x26b46b['id'];if(_0x5da885[_0xa17b('0x39')][_0xa17b('0x42')]){_0x5063ad[_0xa17b('0x43')]=_['merge'](_0x5063ad['where'],{'$or':_[_0xa17b('0x33')](_0x5063ad[_0xa17b('0x3d')],function(_0x43a69a){var _0x2d4a54={};_0x2d4a54[_0x43a69a]={'$like':'%'+_0x5da885[_0xa17b('0x39')][_0xa17b('0x42')]+'%'};return _0x2d4a54;})});}_0x5063ad=_[_0xa17b('0x44')]({},_0x5063ad,_0x5da885[_0xa17b('0x45')]);return db[_0xa17b('0x64')][_0xa17b('0x23')]({'where':_0x5063ad['where']})[_0xa17b('0x46')](function(_0x415611){_0x5b5bd3[_0xa17b('0x23')]=_0x415611;if(_0x5da885['query'][_0xa17b('0x4c')]){_0x5063ad[_0xa17b('0x4d')]=[{'all':!![]}];}return db['JscriptyAnswerReport'][_0xa17b('0x47')](_0x5063ad);})[_0xa17b('0x46')](function(_0x3f564f){_0x5b5bd3[_0xa17b('0x48')]=_0x3f564f;return _0x5b5bd3;});}})[_0xa17b('0x46')](respondWithFilteredResult(_0x3743a1,_0x5063ad))[_0xa17b('0x49')](handleError(_0x3743a1,null));};function char(_0x4cf24b){return _0xa17b('0x65')===typeof _0x4cf24b?String[_0xa17b('0x66')]['apply'](null,arguments):_0x4cf24b;}function needsEncapsulation(_0x1cd0a7){return!!_0x1cd0a7&&(_0x1cd0a7[_0xa17b('0x67')]()[_0xa17b('0x68')](char(0xd))>=0x0||_0x1cd0a7[_0xa17b('0x67')]()[_0xa17b('0x68')](char(0xa))>=0x0||_0x1cd0a7[_0xa17b('0x67')]()[_0xa17b('0x68')](char(0x2c))>=0x0||_0x1cd0a7['toString']()[_0xa17b('0x68')](char(0x22))>=0x0);}function encapsulate(_0x4585be){var _0xaf9082=char(0x22),_0x4d1be8='\x5c'+char(0x22),_0x54604d=_0x4585be[_0xa17b('0x67')]()['replace'](new RegExp(_0xaf9082,'g'),_0x4d1be8);return _0xaf9082+_0x54604d+_0xaf9082;}exports['getSummary']=function(_0x5cd786,_0x1a8885,_0x24d616){var _0x256eba,_0x3a07e5;var _0x35861={'where':{'ProjectId':_0x5cd786['params']['id']}};if(_0x5cd786[_0xa17b('0x39')][_0xa17b('0x69')]){_0x35861[_0xa17b('0x43')][_0xa17b('0x6a')]=JSON['parse'](_0x5cd786[_0xa17b('0x39')]['startTime']);}return db['JscriptySessionReport']['findAll'](_0x35861)[_0xa17b('0x46')](handleEntityNotFound(_0x1a8885,null))['then'](function(_0x12d182){if(_0x12d182){_0x256eba=_0x12d182;return db[_0xa17b('0x6b')]['findAll']({'where':{'SessionId':{'$in':_[_0xa17b('0x33')](_0x256eba,'id')},'ProjectId':_0x5cd786[_0xa17b('0x59')]['id']},'order':'-createdAt'});}})[_0xa17b('0x46')](handleEntityNotFound(_0x1a8885,null))['then'](function(_0x784465){if(_0x784465){_0x3a07e5=_0x784465;var _0x42c4fa={};for(var _0x3a726e=0x0,_0x39ccda=_0x3a07e5['length'];_0x3a726e<_0x39ccda;_0x3a726e++){if(!_0x42c4fa[_0xa17b('0x3f')](_0x3a07e5[_0x3a726e][_0xa17b('0x6c')])){_0x42c4fa[_0x3a07e5[_0x3a726e][_0xa17b('0x6c')]]=needsEncapsulation(_0x3a07e5[_0x3a726e][_0xa17b('0x6d')])?encapsulate(_0x3a07e5[_0x3a726e]['question']):_0x3a07e5[_0x3a726e][_0xa17b('0x6d')];}}var _0x8f8f92=[],_0x4b896e={};for(var _0x33a355=0x0,_0x2893f1=_0x256eba[_0xa17b('0x4b')];_0x33a355<_0x2893f1;_0x33a355++){_0x4b896e={'ProjectId':_0x5cd786[_0xa17b('0x59')]['id'],'SessionId':_0x256eba[_0x33a355]['id'],'StartTime':moment(_0x256eba[_0x33a355]['starttime'])[_0xa17b('0x6e')]('YYYY-MM-DD\x20HH:mm:ss')};for(var _0x1c43aa=0x0,_0x24592b=_0x3a07e5[_0xa17b('0x4b')];_0x1c43aa<_0x24592b;_0x1c43aa++){if(_0x3a07e5[_0x1c43aa]['SessionId']==_0x256eba[_0x33a355]['id']&&_0x42c4fa[_0xa17b('0x3f')](_0x3a07e5[_0x1c43aa][_0xa17b('0x6c')])){_0x4b896e[_0x42c4fa[_0x3a07e5[_0x1c43aa][_0xa17b('0x6c')]]]=_0x3a07e5[_0x1c43aa][_0xa17b('0x6f')];}}for(var _0x31896f in _0x42c4fa){if(!_0x4b896e[_0xa17b('0x3f')](_0x42c4fa[_0x31896f])){_0x4b896e[_0x42c4fa[_0x31896f]]=null;}}_0x8f8f92[_0xa17b('0x70')](_0x4b896e);}return _0x8f8f92;}})[_0xa17b('0x46')](function(_0x12c30c){if(!_['isEmpty'](_0x12c30c)){var _0xefc3df=toCsv(_0x12c30c);var _0x268345=Date[_0xa17b('0x71')]();fs[_0xa17b('0x72')](util['format']('/tmp/Jscripty_Project_%d_Summary_%s.csv',_0x5cd786['params']['id'],_0x268345),_0xefc3df);_0x1a8885[_0xa17b('0x73')]('Content-disposition',_0xa17b('0x74')+util[_0xa17b('0x6e')]('Jscripty_Project_%d_Summary_%s.csv',_0x5cd786[_0xa17b('0x59')]['id'],_0x268345));_0x1a8885[_0xa17b('0x73')](_0xa17b('0x75'),'text/csv');return _0x1a8885[_0xa17b('0x76')](util['format']('/tmp/Jscripty_Project_%d_Summary_%s.csv',_0x5cd786[_0xa17b('0x59')]['id'],_0x268345));}else{return _0x1a8885[_0xa17b('0x1d')](0xcc);}})[_0xa17b('0x49')](handleError(_0x1a8885,null));};
\ No newline at end of file
+var _0xb5fb=['-createdAt','questionId','question','format','YYYY-MM-DD\x20HH:mm:ss','SessionId','answer','push','isEmpty','/tmp/Jscripty_Project_%d_Summary_%s.csv','setHeader','Content-disposition','Jscripty_Project_%d_Summary_%s.csv','Content-type','text/csv','download','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','crypto','desk.js','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','limit','undefined','count','Content-Range','apply','reject','then','Projects','UserProfileResource','destroy','end','error','name','index','map','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','merge','where','options','JscriptyProject','includeAll','include','findAll','rows','catch','show','create','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','createdAt','body','omit','updatedAt','role','UserProfileSection','userProfileId','update','params','getSessions','findOne','JscriptySessionReport','getAnswers','JscriptyAnswerReport','ProjectId','fromCharCode','toString','indexOf','replace','getSummary','starttime','startTime'];(function(_0x338442,_0x327f9d){var _0x3f96b6=function(_0x3cc8dc){while(--_0x3cc8dc){_0x338442['push'](_0x338442['shift']());}};_0x3f96b6(++_0x327f9d);}(_0xb5fb,0x172));var _0xbb5f=function(_0x2484be,_0x12368d){_0x2484be=_0x2484be-0x0;var _0x2953f1=_0xb5fb[_0x2484be];return _0x2953f1;};'use strict';var emlformat=require(_0xbb5f('0x0'));var rimraf=require(_0xbb5f('0x1'));var zipdir=require(_0xbb5f('0x2'));var jsonpatch=require(_0xbb5f('0x3'));var rp=require(_0xbb5f('0x4'));var moment=require(_0xbb5f('0x5'));var BPromise=require(_0xbb5f('0x6'));var Mustache=require(_0xbb5f('0x7'));var util=require(_0xbb5f('0x8'));var path=require(_0xbb5f('0x9'));var sox=require(_0xbb5f('0xa'));var csv=require(_0xbb5f('0xb'));var ejs=require(_0xbb5f('0xc'));var fs=require('fs');var fs_extra=require(_0xbb5f('0xd'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xbb5f('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xbb5f('0xf'));var toCsv=require(_0xbb5f('0xb'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0xbb5f('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xbb5f('0x11'));var as=require(_0xbb5f('0x12'));var hardwareService=require(_0xbb5f('0x13'));var logger=require(_0xbb5f('0x14'))(_0xbb5f('0x15'));var utils=require(_0xbb5f('0x16'));var config=require(_0xbb5f('0x17'));var licenseUtil=require(_0xbb5f('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0xb6c375,_0x5754e0){_0x5754e0=_0x5754e0||0xcc;return function(_0xc0e15a){if(_0xc0e15a){return _0xb6c375[_0xbb5f('0x19')](_0x5754e0);}return _0xb6c375[_0xbb5f('0x1a')](_0x5754e0)['end']();};}function respondWithResult(_0x4315ba,_0xb68b5){_0xb68b5=_0xb68b5||0xc8;return function(_0x5db765){if(_0x5db765){return _0x4315ba[_0xbb5f('0x1a')](_0xb68b5)[_0xbb5f('0x1b')](_0x5db765);}};}function respondWithFilteredResult(_0x3078a8,_0x4085a1){return function(_0x59d9e0){if(_0x59d9e0){var _0x5cf99d=typeof _0x4085a1[_0xbb5f('0x1c')]==='undefined'&&typeof _0x4085a1[_0xbb5f('0x1d')]===_0xbb5f('0x1e');var _0x4efe3a=_0x59d9e0[_0xbb5f('0x1f')];var _0x4cc050=_0x5cf99d?0x0:_0x4085a1[_0xbb5f('0x1c')];var _0xca33c1=_0x5cf99d?_0x59d9e0[_0xbb5f('0x1f')]:_0x4085a1['offset']+_0x4085a1[_0xbb5f('0x1d')];var _0x82ce7e;if(_0xca33c1>=_0x4efe3a){_0xca33c1=_0x4efe3a;_0x82ce7e=0xc8;}else{_0x82ce7e=0xce;}_0x3078a8[_0xbb5f('0x1a')](_0x82ce7e);return _0x3078a8['set'](_0xbb5f('0x20'),_0x4cc050+'-'+_0xca33c1+'/'+_0x4efe3a)['json'](_0x59d9e0);}return null;};}function patchUpdates(_0x7ebb8e){return function(_0x63f1ad){try{jsonpatch[_0xbb5f('0x21')](_0x63f1ad,_0x7ebb8e,!![]);}catch(_0x5533c3){return BPromise[_0xbb5f('0x22')](_0x5533c3);}return _0x63f1ad['save']();};}function saveUpdates(_0x2127d7,_0x540b43){return function(_0x33633f){if(_0x33633f){return _0x33633f['update'](_0x2127d7)[_0xbb5f('0x23')](function(_0x488886){return _0x488886;});}return null;};}function removeEntity(_0x3f5f92,_0xb35efe){return function(_0x1649b8){if(_0x1649b8){return _0x1649b8['destroy']()[_0xbb5f('0x23')](function(){var _0x4de835=_0x1649b8['get']({'plain':!![]});var _0x41be1c=_0xbb5f('0x24');return db[_0xbb5f('0x25')][_0xbb5f('0x26')]({'where':{'type':_0x41be1c,'resourceId':_0x4de835['id']}})[_0xbb5f('0x23')](function(){return _0x1649b8;});})[_0xbb5f('0x23')](function(){_0x3f5f92[_0xbb5f('0x1a')](0xcc)[_0xbb5f('0x27')]();});}};}function handleEntityNotFound(_0x16f5bc,_0x229757){return function(_0xa87ebb){if(!_0xa87ebb){_0x16f5bc[_0xbb5f('0x19')](0x194);}return _0xa87ebb;};}function handleError(_0x187477,_0x26fd51){_0x26fd51=_0x26fd51||0x1f4;return function(_0x14566f){logger[_0xbb5f('0x28')](_0x14566f['stack']);if(_0x14566f['name']){delete _0x14566f[_0xbb5f('0x29')];}_0x187477[_0xbb5f('0x1a')](_0x26fd51)['send'](_0x14566f);};}exports[_0xbb5f('0x2a')]=function(_0x56ca55,_0x3ea574){var _0x30641a={},_0xa2adf2={},_0x24e8c2={'count':0x0,'rows':[]};var _0x22d528=_[_0xbb5f('0x2b')](db['JscriptyProject'][_0xbb5f('0x2c')],function(_0x3c720b){return{'name':_0x3c720b[_0xbb5f('0x2d')],'type':_0x3c720b[_0xbb5f('0x2e')][_0xbb5f('0x2f')]};});_0xa2adf2[_0xbb5f('0x30')]=_[_0xbb5f('0x2b')](_0x22d528,_0xbb5f('0x29'));_0xa2adf2[_0xbb5f('0x31')]=_[_0xbb5f('0x32')](_0x56ca55[_0xbb5f('0x31')]);_0xa2adf2[_0xbb5f('0x33')]=_['intersection'](_0xa2adf2[_0xbb5f('0x30')],_0xa2adf2[_0xbb5f('0x31')]);_0x30641a['attributes']=_[_0xbb5f('0x34')](_0xa2adf2['model'],qs[_0xbb5f('0x35')](_0x56ca55['query']['fields']));_0x30641a[_0xbb5f('0x36')]=_0x30641a[_0xbb5f('0x36')][_0xbb5f('0x37')]?_0x30641a[_0xbb5f('0x36')]:_0xa2adf2[_0xbb5f('0x30')];if(!_0x56ca55[_0xbb5f('0x31')][_0xbb5f('0x38')](_0xbb5f('0x39'))){_0x30641a[_0xbb5f('0x1d')]=qs[_0xbb5f('0x1d')](_0x56ca55[_0xbb5f('0x31')][_0xbb5f('0x1d')]);_0x30641a[_0xbb5f('0x1c')]=qs['offset'](_0x56ca55[_0xbb5f('0x31')][_0xbb5f('0x1c')]);}_0x30641a[_0xbb5f('0x3a')]=qs[_0xbb5f('0x3b')](_0x56ca55['query'][_0xbb5f('0x3b')]);_0x30641a['where']=qs[_0xbb5f('0x33')](_[_0xbb5f('0x3c')](_0x56ca55[_0xbb5f('0x31')],_0xa2adf2[_0xbb5f('0x33')]),_0x22d528);if(_0x56ca55[_0xbb5f('0x31')][_0xbb5f('0x3d')]){_0x30641a['where']=_[_0xbb5f('0x3e')](_0x30641a[_0xbb5f('0x3f')],{'$or':_[_0xbb5f('0x2b')](_0x22d528,function(_0x20f0ad){if(_0x20f0ad['type']!=='VIRTUAL'){var _0x5dc398={};_0x5dc398[_0x20f0ad[_0xbb5f('0x29')]]={'$like':'%'+_0x56ca55[_0xbb5f('0x31')][_0xbb5f('0x3d')]+'%'};return _0x5dc398;}})});}_0x30641a=_['merge']({},_0x30641a,_0x56ca55[_0xbb5f('0x40')]);var _0x408c84={'where':_0x30641a['where']};return db[_0xbb5f('0x41')][_0xbb5f('0x1f')](_0x408c84)['then'](function(_0x313a67){_0x24e8c2[_0xbb5f('0x1f')]=_0x313a67;if(_0x56ca55[_0xbb5f('0x31')][_0xbb5f('0x42')]){_0x30641a[_0xbb5f('0x43')]=[{'all':!![]}];}return db[_0xbb5f('0x41')][_0xbb5f('0x44')](_0x30641a);})[_0xbb5f('0x23')](function(_0x4a8af4){_0x24e8c2[_0xbb5f('0x45')]=_0x4a8af4;return _0x24e8c2;})[_0xbb5f('0x23')](respondWithFilteredResult(_0x3ea574,_0x30641a))[_0xbb5f('0x46')](handleError(_0x3ea574,null));};exports[_0xbb5f('0x47')]=function(_0x50ebe7,_0x2e0608){var _0x4d8961={'raw':![],'where':{'id':_0x50ebe7['params']['id']}},_0x3c6fee={};_0x3c6fee[_0xbb5f('0x30')]=_[_0xbb5f('0x32')](db[_0xbb5f('0x41')][_0xbb5f('0x2c')]);_0x3c6fee[_0xbb5f('0x31')]=_[_0xbb5f('0x32')](_0x50ebe7['query']);_0x3c6fee[_0xbb5f('0x33')]=_[_0xbb5f('0x34')](_0x3c6fee['model'],_0x3c6fee['query']);_0x4d8961[_0xbb5f('0x36')]=_[_0xbb5f('0x34')](_0x3c6fee['model'],qs[_0xbb5f('0x35')](_0x50ebe7[_0xbb5f('0x31')][_0xbb5f('0x35')]));_0x4d8961['attributes']=_0x4d8961[_0xbb5f('0x36')][_0xbb5f('0x37')]?_0x4d8961[_0xbb5f('0x36')]:_0x3c6fee['model'];if(_0x50ebe7['query'][_0xbb5f('0x42')]){_0x4d8961[_0xbb5f('0x43')]=[{'all':!![]}];}_0x4d8961=_[_0xbb5f('0x3e')]({},_0x4d8961,_0x50ebe7[_0xbb5f('0x40')]);return db['JscriptyProject']['find'](_0x4d8961)[_0xbb5f('0x23')](handleEntityNotFound(_0x2e0608,null))[_0xbb5f('0x23')](respondWithResult(_0x2e0608,null))['catch'](handleError(_0x2e0608,null));};exports[_0xbb5f('0x48')]=function(_0x3f1fe6,_0x5a21cc){return db[_0xbb5f('0x41')][_0xbb5f('0x48')](_0x3f1fe6['body'],{})[_0xbb5f('0x23')](function(_0x144305){var _0x4a062c=_0x3f1fe6['user'][_0xbb5f('0x49')]({'plain':!![]});if(!_0x4a062c)throw new Error(_0xbb5f('0x4a'));if(_0x4a062c['role']===_0xbb5f('0x4b')){var _0x9b1906=_0x144305[_0xbb5f('0x49')]({'plain':!![]});var _0x3fc42d='Projects';return db['UserProfileSection'][_0xbb5f('0x4c')]({'where':{'name':_0x3fc42d,'userProfileId':_0x4a062c['userProfileId']},'raw':!![]})['then'](function(_0xe88d9e){if(_0xe88d9e&&_0xe88d9e[_0xbb5f('0x4d')]===0x0){return db['UserProfileResource'][_0xbb5f('0x48')]({'name':_0x9b1906[_0xbb5f('0x29')],'resourceId':_0x9b1906['id'],'type':_0xe88d9e[_0xbb5f('0x29')],'sectionId':_0xe88d9e['id']},{})['then'](function(){return _0x144305;});}else{return _0x144305;}})[_0xbb5f('0x46')](function(_0x118de3){logger[_0xbb5f('0x28')](_0xbb5f('0x4e'),_0x118de3);throw _0x118de3;});}return _0x144305;})['then'](respondWithResult(_0x5a21cc,0xc9))['catch'](handleError(_0x5a21cc,null));};exports[_0xbb5f('0x4f')]=function(_0x5dbe1a,_0x52cad4){var _0x44de07={'where':{'id':_0x5dbe1a['params']['id']}},_0xcbbbc7={};_0xcbbbc7[_0xbb5f('0x30')]=_[_0xbb5f('0x32')](db['JscriptyProject'][_0xbb5f('0x2c')]);_0x44de07[_0xbb5f('0x36')]=_[_0xbb5f('0x34')](_0xcbbbc7['model'],qs[_0xbb5f('0x35')](_0x5dbe1a[_0xbb5f('0x31')][_0xbb5f('0x35')]));_0x44de07[_0xbb5f('0x36')]=_0x44de07[_0xbb5f('0x36')][_0xbb5f('0x37')]?_0x44de07[_0xbb5f('0x36')]:_0xcbbbc7[_0xbb5f('0x30')];if(_0x5dbe1a[_0xbb5f('0x31')][_0xbb5f('0x42')]){_0x44de07['include']=[{'all':!![]}];}_0x44de07=_[_0xbb5f('0x3e')]({},_0x44de07,_0x5dbe1a[_0xbb5f('0x40')]);return db['JscriptyProject'][_0xbb5f('0x4c')](_0x44de07)[_0xbb5f('0x23')](handleEntityNotFound(_0x52cad4,null))[_0xbb5f('0x23')](function(_0x337485){if(_0x337485){var _0x1f73cf=_0x337485[_0xbb5f('0x49')]({'plain':!![]});_0x1f73cf=qs['omit'](_0x1f73cf,['id',_0xbb5f('0x50'),'updatedAt']);_0x5dbe1a[_0xbb5f('0x51')]=_[_0xbb5f('0x52')](_0x5dbe1a[_0xbb5f('0x51')],['id',_0xbb5f('0x50'),_0xbb5f('0x53')]);return db['JscriptyProject'][_0xbb5f('0x48')](_[_0xbb5f('0x3e')](_0x1f73cf,_0x5dbe1a[_0xbb5f('0x51')]),{'include':_0x5dbe1a['query'][_0xbb5f('0x42')]?[{'all':!![]}]:undefined})[_0xbb5f('0x23')](function(_0x4b2d0f){var _0x50731c=_0x5dbe1a[_0xbb5f('0x4b')][_0xbb5f('0x49')]({'plain':!![]});if(!_0x50731c)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x50731c[_0xbb5f('0x54')]==='user'){var _0x588a31=_0x4b2d0f['get']({'plain':!![]});var _0x4d69a8=_0xbb5f('0x24');return db[_0xbb5f('0x55')][_0xbb5f('0x4c')]({'where':{'name':_0x4d69a8,'userProfileId':_0x50731c[_0xbb5f('0x56')]},'raw':!![]})[_0xbb5f('0x23')](function(_0x1706a6){if(_0x1706a6&&_0x1706a6['autoAssociation']===0x0){return db[_0xbb5f('0x25')][_0xbb5f('0x48')]({'name':_0x588a31[_0xbb5f('0x29')],'resourceId':_0x588a31['id'],'type':_0x1706a6[_0xbb5f('0x29')],'sectionId':_0x1706a6['id']},{})[_0xbb5f('0x23')](function(){return _0x4b2d0f;});}else{return _0x4b2d0f;}})[_0xbb5f('0x46')](function(_0x235a73){logger[_0xbb5f('0x28')](_0xbb5f('0x4e'),_0x235a73);throw _0x235a73;});}return _0x4b2d0f;});}})[_0xbb5f('0x23')](respondWithResult(_0x52cad4,0xc9))[_0xbb5f('0x46')](handleError(_0x52cad4,null));};exports[_0xbb5f('0x57')]=function(_0x743f3b,_0x35640e){if(_0x743f3b['body']['id']){delete _0x743f3b[_0xbb5f('0x51')]['id'];}return db[_0xbb5f('0x41')][_0xbb5f('0x4c')]({'where':{'id':_0x743f3b[_0xbb5f('0x58')]['id']}})[_0xbb5f('0x23')](handleEntityNotFound(_0x35640e,null))[_0xbb5f('0x23')](saveUpdates(_0x743f3b['body'],null))[_0xbb5f('0x23')](respondWithResult(_0x35640e,null))['catch'](handleError(_0x35640e,null));};exports[_0xbb5f('0x26')]=function(_0x3e260c,_0x23d18b){return db['JscriptyProject'][_0xbb5f('0x4c')]({'where':{'id':_0x3e260c['params']['id']}})[_0xbb5f('0x23')](handleEntityNotFound(_0x23d18b,null))[_0xbb5f('0x23')](removeEntity(_0x23d18b,null))[_0xbb5f('0x46')](handleError(_0x23d18b,null));};exports[_0xbb5f('0x59')]=function(_0x34e20b,_0x5cb244,_0xf8442a){var _0x516ba8={'raw':!![],'where':{}};var _0x3f84df={};var _0x221fdd={'count':0x0,'rows':[]};return db[_0xbb5f('0x41')][_0xbb5f('0x5a')]({'where':{'id':_0x34e20b[_0xbb5f('0x58')]['id']}})[_0xbb5f('0x23')](handleEntityNotFound(_0x5cb244,null))[_0xbb5f('0x23')](function(_0x31ef4c){if(_0x31ef4c){_0x3f84df['model']=_[_0xbb5f('0x32')](db['JscriptySessionReport'][_0xbb5f('0x2c')]);_0x3f84df[_0xbb5f('0x31')]=_['keys'](_0x34e20b[_0xbb5f('0x31')]);_0x3f84df['filters']=_[_0xbb5f('0x34')](_0x3f84df[_0xbb5f('0x30')],_0x3f84df['query']);_0x516ba8[_0xbb5f('0x36')]=_[_0xbb5f('0x34')](_0x3f84df[_0xbb5f('0x30')],qs[_0xbb5f('0x35')](_0x34e20b[_0xbb5f('0x31')][_0xbb5f('0x35')]));_0x516ba8['attributes']=_0x516ba8[_0xbb5f('0x36')]['length']?_0x516ba8['attributes']:_0x3f84df[_0xbb5f('0x30')];if(!_0x34e20b[_0xbb5f('0x31')][_0xbb5f('0x38')]('nolimit')){_0x516ba8['limit']=qs[_0xbb5f('0x1d')](_0x34e20b[_0xbb5f('0x31')]['limit']);_0x516ba8[_0xbb5f('0x1c')]=qs[_0xbb5f('0x1c')](_0x34e20b[_0xbb5f('0x31')]['offset']);}_0x516ba8[_0xbb5f('0x3a')]=qs[_0xbb5f('0x3b')](_0x34e20b[_0xbb5f('0x31')][_0xbb5f('0x3b')]);_0x516ba8[_0xbb5f('0x3f')]=qs[_0xbb5f('0x33')](_['pick'](_0x34e20b[_0xbb5f('0x31')],_0x3f84df['filters']));_0x516ba8[_0xbb5f('0x3f')]['ProjectId']=_0x31ef4c['id'];if(_0x34e20b[_0xbb5f('0x31')][_0xbb5f('0x3d')]){_0x516ba8['where']=_[_0xbb5f('0x3e')](_0x516ba8[_0xbb5f('0x3f')],{'$or':_['map'](_0x516ba8[_0xbb5f('0x36')],function(_0x19ebee){var _0x35b138={};_0x35b138[_0x19ebee]={'$like':'%'+_0x34e20b[_0xbb5f('0x31')][_0xbb5f('0x3d')]+'%'};return _0x35b138;})});}_0x516ba8=_['merge']({},_0x516ba8,_0x34e20b[_0xbb5f('0x40')]);return db[_0xbb5f('0x5b')][_0xbb5f('0x1f')]({'where':_0x516ba8[_0xbb5f('0x3f')]})[_0xbb5f('0x23')](function(_0x50c3b4){_0x221fdd[_0xbb5f('0x1f')]=_0x50c3b4;if(_0x34e20b[_0xbb5f('0x31')][_0xbb5f('0x42')]){_0x516ba8[_0xbb5f('0x43')]=[{'all':!![]}];}return db[_0xbb5f('0x5b')]['findAll'](_0x516ba8);})[_0xbb5f('0x23')](function(_0x5eb1b2){_0x221fdd['rows']=_0x5eb1b2;return _0x221fdd;});}})[_0xbb5f('0x23')](respondWithFilteredResult(_0x5cb244,_0x516ba8))[_0xbb5f('0x46')](handleError(_0x5cb244,null));};exports[_0xbb5f('0x5c')]=function(_0x4dc0da,_0x1cf2e7,_0x495382){var _0x111acb={'raw':!![],'where':{}};var _0x13fe18={};var _0x5284b7={'count':0x0,'rows':[]};return db[_0xbb5f('0x41')][_0xbb5f('0x5a')]({'where':{'id':_0x4dc0da[_0xbb5f('0x58')]['id']}})[_0xbb5f('0x23')](handleEntityNotFound(_0x1cf2e7,null))[_0xbb5f('0x23')](function(_0x37279c){if(_0x37279c){_0x13fe18[_0xbb5f('0x30')]=_[_0xbb5f('0x32')](db[_0xbb5f('0x5d')][_0xbb5f('0x2c')]);_0x13fe18['query']=_[_0xbb5f('0x32')](_0x4dc0da[_0xbb5f('0x31')]);_0x13fe18[_0xbb5f('0x33')]=_[_0xbb5f('0x34')](_0x13fe18['model'],_0x13fe18[_0xbb5f('0x31')]);_0x111acb[_0xbb5f('0x36')]=_[_0xbb5f('0x34')](_0x13fe18[_0xbb5f('0x30')],qs[_0xbb5f('0x35')](_0x4dc0da[_0xbb5f('0x31')][_0xbb5f('0x35')]));_0x111acb[_0xbb5f('0x36')]=_0x111acb[_0xbb5f('0x36')]['length']?_0x111acb['attributes']:_0x13fe18[_0xbb5f('0x30')];if(!_0x4dc0da[_0xbb5f('0x31')]['hasOwnProperty']('nolimit')){_0x111acb[_0xbb5f('0x1d')]=qs[_0xbb5f('0x1d')](_0x4dc0da['query'][_0xbb5f('0x1d')]);_0x111acb[_0xbb5f('0x1c')]=qs[_0xbb5f('0x1c')](_0x4dc0da[_0xbb5f('0x31')]['offset']);}_0x111acb['order']=qs[_0xbb5f('0x3b')](_0x4dc0da[_0xbb5f('0x31')][_0xbb5f('0x3b')]);_0x111acb[_0xbb5f('0x3f')]=qs[_0xbb5f('0x33')](_[_0xbb5f('0x3c')](_0x4dc0da[_0xbb5f('0x31')],_0x13fe18[_0xbb5f('0x33')]));_0x111acb[_0xbb5f('0x3f')][_0xbb5f('0x5e')]=_0x37279c['id'];if(_0x4dc0da[_0xbb5f('0x31')][_0xbb5f('0x3d')]){_0x111acb['where']=_[_0xbb5f('0x3e')](_0x111acb[_0xbb5f('0x3f')],{'$or':_[_0xbb5f('0x2b')](_0x111acb[_0xbb5f('0x36')],function(_0x268f39){var _0x2b2594={};_0x2b2594[_0x268f39]={'$like':'%'+_0x4dc0da[_0xbb5f('0x31')][_0xbb5f('0x3d')]+'%'};return _0x2b2594;})});}_0x111acb=_[_0xbb5f('0x3e')]({},_0x111acb,_0x4dc0da['options']);return db[_0xbb5f('0x5d')][_0xbb5f('0x1f')]({'where':_0x111acb[_0xbb5f('0x3f')]})[_0xbb5f('0x23')](function(_0x2dfb5c){_0x5284b7[_0xbb5f('0x1f')]=_0x2dfb5c;if(_0x4dc0da['query'][_0xbb5f('0x42')]){_0x111acb[_0xbb5f('0x43')]=[{'all':!![]}];}return db[_0xbb5f('0x5d')]['findAll'](_0x111acb);})[_0xbb5f('0x23')](function(_0x28f36d){_0x5284b7[_0xbb5f('0x45')]=_0x28f36d;return _0x5284b7;});}})[_0xbb5f('0x23')](respondWithFilteredResult(_0x1cf2e7,_0x111acb))['catch'](handleError(_0x1cf2e7,null));};function char(_0x44b665){return'number'===typeof _0x44b665?String[_0xbb5f('0x5f')][_0xbb5f('0x21')](null,arguments):_0x44b665;}function needsEncapsulation(_0x5cfd26){return!!_0x5cfd26&&(_0x5cfd26[_0xbb5f('0x60')]()['indexOf'](char(0xd))>=0x0||_0x5cfd26[_0xbb5f('0x60')]()[_0xbb5f('0x61')](char(0xa))>=0x0||_0x5cfd26[_0xbb5f('0x60')]()['indexOf'](char(0x2c))>=0x0||_0x5cfd26[_0xbb5f('0x60')]()[_0xbb5f('0x61')](char(0x22))>=0x0);}function encapsulate(_0x5901a7){var _0xac3000=char(0x22),_0x2928f4='\x5c'+char(0x22),_0x427c4e=_0x5901a7[_0xbb5f('0x60')]()[_0xbb5f('0x62')](new RegExp(_0xac3000,'g'),_0x2928f4);return _0xac3000+_0x427c4e+_0xac3000;}exports[_0xbb5f('0x63')]=function(_0x571b2b,_0x42908a,_0x1814fd){var _0x275fe7,_0x2f7e50;var _0x1f9286={'where':{'ProjectId':_0x571b2b['params']['id']}};if(_0x571b2b[_0xbb5f('0x31')]['startTime']){_0x1f9286[_0xbb5f('0x3f')][_0xbb5f('0x64')]=JSON['parse'](_0x571b2b[_0xbb5f('0x31')][_0xbb5f('0x65')]);}return db['JscriptySessionReport'][_0xbb5f('0x44')](_0x1f9286)[_0xbb5f('0x23')](handleEntityNotFound(_0x42908a,null))[_0xbb5f('0x23')](function(_0x523536){if(_0x523536){_0x275fe7=_0x523536;return db['JscriptyQuestionReport'][_0xbb5f('0x44')]({'where':{'SessionId':{'$in':_[_0xbb5f('0x2b')](_0x275fe7,'id')},'ProjectId':_0x571b2b[_0xbb5f('0x58')]['id']},'order':_0xbb5f('0x66')});}})[_0xbb5f('0x23')](handleEntityNotFound(_0x42908a,null))['then'](function(_0x33cf16){if(_0x33cf16){_0x2f7e50=_0x33cf16;var _0x4c7aac={};for(var _0x544a1e=0x0,_0x5262b8=_0x2f7e50['length'];_0x544a1e<_0x5262b8;_0x544a1e++){if(!_0x4c7aac[_0xbb5f('0x38')](_0x2f7e50[_0x544a1e][_0xbb5f('0x67')])){_0x4c7aac[_0x2f7e50[_0x544a1e]['questionId']]=needsEncapsulation(_0x2f7e50[_0x544a1e][_0xbb5f('0x68')])?encapsulate(_0x2f7e50[_0x544a1e][_0xbb5f('0x68')]):_0x2f7e50[_0x544a1e][_0xbb5f('0x68')];}}var _0x4144bc=[],_0xa934da={};for(var _0x2a110a=0x0,_0x396250=_0x275fe7[_0xbb5f('0x37')];_0x2a110a<_0x396250;_0x2a110a++){_0xa934da={'ProjectId':_0x571b2b['params']['id'],'SessionId':_0x275fe7[_0x2a110a]['id'],'StartTime':moment(_0x275fe7[_0x2a110a]['starttime'])[_0xbb5f('0x69')](_0xbb5f('0x6a'))};for(var _0x11a992=0x0,_0x431411=_0x2f7e50[_0xbb5f('0x37')];_0x11a992<_0x431411;_0x11a992++){if(_0x2f7e50[_0x11a992][_0xbb5f('0x6b')]==_0x275fe7[_0x2a110a]['id']&&_0x4c7aac[_0xbb5f('0x38')](_0x2f7e50[_0x11a992][_0xbb5f('0x67')])){_0xa934da[_0x4c7aac[_0x2f7e50[_0x11a992][_0xbb5f('0x67')]]]=_0x2f7e50[_0x11a992][_0xbb5f('0x6c')];}}for(var _0x27a4c0 in _0x4c7aac){if(!_0xa934da[_0xbb5f('0x38')](_0x4c7aac[_0x27a4c0])){_0xa934da[_0x4c7aac[_0x27a4c0]]=null;}}_0x4144bc[_0xbb5f('0x6d')](_0xa934da);}return _0x4144bc;}})[_0xbb5f('0x23')](function(_0x1affe6){if(!_[_0xbb5f('0x6e')](_0x1affe6)){var _0x12f99a=toCsv(_0x1affe6);var _0x1b7061=Date['now']();fs['writeFileSync'](util['format'](_0xbb5f('0x6f'),_0x571b2b[_0xbb5f('0x58')]['id'],_0x1b7061),_0x12f99a);_0x42908a[_0xbb5f('0x70')](_0xbb5f('0x71'),'attachment;\x20filename='+util[_0xbb5f('0x69')](_0xbb5f('0x72'),_0x571b2b['params']['id'],_0x1b7061));_0x42908a[_0xbb5f('0x70')](_0xbb5f('0x73'),_0xbb5f('0x74'));return _0x42908a[_0xbb5f('0x75')](util[_0xbb5f('0x69')](_0xbb5f('0x6f'),_0x571b2b[_0xbb5f('0x58')]['id'],_0x1b7061));}else{return _0x42908a[_0xbb5f('0x19')](0xcc);}})['catch'](handleError(_0x42908a,null));};
\ No newline at end of file