Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / api / jscriptyProject / jscriptyProject.controller.js
index afa38ff..7994d93 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf749=['isEmpty','now','writeFileSync','/tmp/Jscripty_Project_%d_Summary_%s.csv','setHeader','attachment;\x20filename=','Jscripty_Project_%d_Summary_%s.csv','Content-type','text/csv','download','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','update','destroy','then','get','Projects','UserProfileResource','error','name','send','rawAttributes','fieldName','type','key','model','map','query','intersection','fields','attributes','hasOwnProperty','order','sort','filters','pick','filter','where','merge','options','includeAll','JscriptyProject','findAll','rows','show','params','keys','include','find','create','user','role','userProfileId','autoAssociation','catch','clone','length','omit','createdAt','updatedAt','body','UserProfileSection','getSessions','findOne','JscriptySessionReport','nolimit','JscriptyAnswerReport','number','fromCharCode','toString','indexOf','replace','getSummary','startTime','starttime','parse','JscriptyQuestionReport','-createdAt','questionId','question','format','SessionId','answer','push'];(function(_0x167cc1,_0x56ef5a){var _0x10bc4b=function(_0xd6a255){while(--_0xd6a255){_0x167cc1['push'](_0x167cc1['shift']());}};_0x10bc4b(++_0x56ef5a);}(_0xf749,0xf0));var _0x9f74=function(_0x57b54c,_0x54ce0d){_0x57b54c=_0x57b54c-0x0;var _0x59cc19=_0xf749[_0x57b54c];return _0x59cc19;};'use strict';var pdf=require(_0x9f74('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x9f74('0x1'));var zipdir=require(_0x9f74('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9f74('0x3'));var moment=require(_0x9f74('0x4'));var BPromise=require(_0x9f74('0x5'));var Mustache=require(_0x9f74('0x6'));var util=require(_0x9f74('0x7'));var path=require(_0x9f74('0x8'));var sox=require('sox');var csv=require(_0x9f74('0x9'));var ejs=require(_0x9f74('0xa'));var fs=require('fs');var _=require(_0x9f74('0xb'));var squel=require(_0x9f74('0xc'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x9f74('0x9'));var querystring=require(_0x9f74('0xd'));var Papa=require(_0x9f74('0xe'));var Redis=require(_0x9f74('0xf'));var authService=require(_0x9f74('0x10'));var qs=require(_0x9f74('0x11'));var as=require(_0x9f74('0x12'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x9f74('0x13'))(_0x9f74('0x14'));var utils=require('../../config/utils');var config=require(_0x9f74('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x289d28,_0x2dcced){_0x2dcced=_0x2dcced||0xcc;return function(_0x1f820d){if(_0x1f820d){return _0x289d28[_0x9f74('0x16')](_0x2dcced);}return _0x289d28[_0x9f74('0x17')](_0x2dcced)[_0x9f74('0x18')]();};}function respondWithResult(_0x2ec61d,_0x39f352){_0x39f352=_0x39f352||0xc8;return function(_0x3df5bd){if(_0x3df5bd){return _0x2ec61d['status'](_0x39f352)[_0x9f74('0x19')](_0x3df5bd);}};}function respondWithFilteredResult(_0x238480,_0x1de9f4){return function(_0x599055){if(_0x599055){var _0x51a00f=_0x599055[_0x9f74('0x1a')],_0x2bbd47=_0x1de9f4['offset'],_0x1c00e6=_0x1de9f4[_0x9f74('0x1b')]+_0x1de9f4[_0x9f74('0x1c')],_0x230876;if(_0x1c00e6>=_0x51a00f){_0x1c00e6=_0x51a00f;_0x230876=0xc8;}else{_0x230876=0xce;}_0x238480[_0x9f74('0x17')](_0x230876);return _0x238480[_0x9f74('0x1d')](_0x9f74('0x1e'),_0x2bbd47+'-'+_0x1c00e6+'/'+_0x51a00f)['json'](_0x599055);}return null;};}function patchUpdates(_0x1278e4){return function(_0x46e5dd){try{jsonpatch[_0x9f74('0x1f')](_0x46e5dd,_0x1278e4,!![]);}catch(_0x295fab){return BPromise[_0x9f74('0x20')](_0x295fab);}return _0x46e5dd['save']();};}function saveUpdates(_0x1081eb,_0x5db1c9){return function(_0x4446ea){if(_0x4446ea){return _0x4446ea[_0x9f74('0x21')](_0x1081eb)['then'](function(_0x4b9371){return _0x4b9371;});}return null;};}function removeEntity(_0x4ca25d,_0x393f37){return function(_0x116da4){if(_0x116da4){return _0x116da4[_0x9f74('0x22')]()[_0x9f74('0x23')](function(){var _0x1385b6=_0x116da4[_0x9f74('0x24')]({'plain':!![]});var _0x365168=_0x9f74('0x25');return db[_0x9f74('0x26')][_0x9f74('0x22')]({'where':{'type':_0x365168,'resourceId':_0x1385b6['id']}})[_0x9f74('0x23')](function(){return _0x116da4;});})[_0x9f74('0x23')](function(){_0x4ca25d['status'](0xcc)[_0x9f74('0x18')]();});}};}function handleEntityNotFound(_0x578f38,_0x5036d0){return function(_0x443fcc){if(!_0x443fcc){_0x578f38[_0x9f74('0x16')](0x194);}return _0x443fcc;};}function handleError(_0x1e3d01,_0x1326a8){_0x1326a8=_0x1326a8||0x1f4;return function(_0x3c2133){logger[_0x9f74('0x27')](_0x3c2133['stack']);if(_0x3c2133[_0x9f74('0x28')]){delete _0x3c2133[_0x9f74('0x28')];}_0x1e3d01[_0x9f74('0x17')](_0x1326a8)[_0x9f74('0x29')](_0x3c2133);};}exports['index']=function(_0x3bc14a,_0x3b106d){var _0x1aa123={},_0x150626={},_0x42c780={'count':0x0,'rows':[]};var _0x63ca49=_['map'](db['JscriptyProject'][_0x9f74('0x2a')],function(_0x7456bf){return{'name':_0x7456bf[_0x9f74('0x2b')],'type':_0x7456bf[_0x9f74('0x2c')][_0x9f74('0x2d')]};});_0x150626[_0x9f74('0x2e')]=_[_0x9f74('0x2f')](_0x63ca49,_0x9f74('0x28'));_0x150626[_0x9f74('0x30')]=_['keys'](_0x3bc14a[_0x9f74('0x30')]);_0x150626['filters']=_['intersection'](_0x150626['model'],_0x150626[_0x9f74('0x30')]);_0x1aa123['attributes']=_[_0x9f74('0x31')](_0x150626[_0x9f74('0x2e')],qs[_0x9f74('0x32')](_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x32')]));_0x1aa123[_0x9f74('0x33')]=_0x1aa123[_0x9f74('0x33')]['length']?_0x1aa123['attributes']:_0x150626[_0x9f74('0x2e')];if(!_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x34')]('nolimit')){_0x1aa123[_0x9f74('0x1c')]=qs[_0x9f74('0x1c')](_0x3bc14a['query']['limit']);_0x1aa123[_0x9f74('0x1b')]=qs['offset'](_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x1b')]);}_0x1aa123[_0x9f74('0x35')]=qs['sort'](_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x36')]);_0x1aa123['where']=qs[_0x9f74('0x37')](_[_0x9f74('0x38')](_0x3bc14a[_0x9f74('0x30')],_0x150626[_0x9f74('0x37')]));if(_0x3bc14a['query'][_0x9f74('0x39')]){_0x1aa123[_0x9f74('0x3a')]=_[_0x9f74('0x3b')](_0x1aa123[_0x9f74('0x3a')],{'$or':_[_0x9f74('0x2f')](_0x63ca49,function(_0x5e6433){if(_0x5e6433[_0x9f74('0x2c')]!=='VIRTUAL'){var _0x3553df={};_0x3553df[_0x5e6433[_0x9f74('0x28')]]={'$like':'%'+_0x3bc14a['query']['filter']+'%'};return _0x3553df;}})});}_0x1aa123=_[_0x9f74('0x3b')]({},_0x1aa123,_0x3bc14a[_0x9f74('0x3c')]);var _0x334c22={'where':_0x1aa123['where']};return db['JscriptyProject'][_0x9f74('0x1a')](_0x334c22)[_0x9f74('0x23')](function(_0x1f5851){_0x42c780['count']=_0x1f5851;if(_0x3bc14a[_0x9f74('0x30')][_0x9f74('0x3d')]){_0x1aa123['include']=[{'all':!![]}];}return db[_0x9f74('0x3e')][_0x9f74('0x3f')](_0x1aa123);})[_0x9f74('0x23')](function(_0x25eac0){_0x42c780[_0x9f74('0x40')]=_0x25eac0;return _0x42c780;})['then'](respondWithFilteredResult(_0x3b106d,_0x1aa123))['catch'](handleError(_0x3b106d,null));};exports[_0x9f74('0x41')]=function(_0x53919f,_0x398910){var _0x514ff3={'raw':![],'where':{'id':_0x53919f[_0x9f74('0x42')]['id']}},_0x6846be={};_0x6846be[_0x9f74('0x2e')]=_[_0x9f74('0x43')](db[_0x9f74('0x3e')][_0x9f74('0x2a')]);_0x6846be[_0x9f74('0x30')]=_[_0x9f74('0x43')](_0x53919f[_0x9f74('0x30')]);_0x6846be[_0x9f74('0x37')]=_[_0x9f74('0x31')](_0x6846be[_0x9f74('0x2e')],_0x6846be[_0x9f74('0x30')]);_0x514ff3['attributes']=_[_0x9f74('0x31')](_0x6846be[_0x9f74('0x2e')],qs[_0x9f74('0x32')](_0x53919f['query']['fields']));_0x514ff3[_0x9f74('0x33')]=_0x514ff3[_0x9f74('0x33')]['length']?_0x514ff3[_0x9f74('0x33')]:_0x6846be[_0x9f74('0x2e')];if(_0x53919f[_0x9f74('0x30')][_0x9f74('0x3d')]){_0x514ff3[_0x9f74('0x44')]=[{'all':!![]}];}_0x514ff3=_[_0x9f74('0x3b')]({},_0x514ff3,_0x53919f['options']);return db[_0x9f74('0x3e')][_0x9f74('0x45')](_0x514ff3)[_0x9f74('0x23')](handleEntityNotFound(_0x398910,null))[_0x9f74('0x23')](respondWithResult(_0x398910,null))['catch'](handleError(_0x398910,null));};exports[_0x9f74('0x46')]=function(_0x355dab,_0x301515){return db[_0x9f74('0x3e')][_0x9f74('0x46')](_0x355dab['body'],{})[_0x9f74('0x23')](function(_0x464e1a){var _0x14a306=_0x355dab[_0x9f74('0x47')]['get']({'plain':!![]});if(!_0x14a306)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x14a306[_0x9f74('0x48')]===_0x9f74('0x47')){var _0x4f4c1a=_0x464e1a[_0x9f74('0x24')]({'plain':!![]});var _0x502f77='Projects';return db['UserProfileSection']['find']({'where':{'name':_0x502f77,'userProfileId':_0x14a306[_0x9f74('0x49')]},'raw':!![]})[_0x9f74('0x23')](function(_0x4bb2bf){if(_0x4bb2bf&&_0x4bb2bf[_0x9f74('0x4a')]===0x0){return db[_0x9f74('0x26')]['create']({'name':_0x4f4c1a[_0x9f74('0x28')],'resourceId':_0x4f4c1a['id'],'type':_0x4bb2bf[_0x9f74('0x28')],'sectionId':_0x4bb2bf['id']},{})[_0x9f74('0x23')](function(){return _0x464e1a;});}else{return _0x464e1a;}})[_0x9f74('0x4b')](function(_0x133757){logger[_0x9f74('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x133757);throw _0x133757;});}return _0x464e1a;})[_0x9f74('0x23')](respondWithResult(_0x301515,0xc9))[_0x9f74('0x4b')](handleError(_0x301515,null));};exports[_0x9f74('0x4c')]=function(_0x3478b2,_0x5b56a){var _0x2b18f9={'where':{'id':_0x3478b2[_0x9f74('0x42')]['id']}},_0x156ba7={};_0x156ba7[_0x9f74('0x2e')]=_['keys'](db[_0x9f74('0x3e')][_0x9f74('0x2a')]);_0x2b18f9[_0x9f74('0x33')]=_[_0x9f74('0x31')](_0x156ba7[_0x9f74('0x2e')],qs['fields'](_0x3478b2[_0x9f74('0x30')]['fields']));_0x2b18f9[_0x9f74('0x33')]=_0x2b18f9[_0x9f74('0x33')][_0x9f74('0x4d')]?_0x2b18f9[_0x9f74('0x33')]:_0x156ba7[_0x9f74('0x2e')];if(_0x3478b2[_0x9f74('0x30')][_0x9f74('0x3d')]){_0x2b18f9['include']=[{'all':!![]}];}_0x2b18f9=_[_0x9f74('0x3b')]({},_0x2b18f9,_0x3478b2['options']);return db[_0x9f74('0x3e')][_0x9f74('0x45')](_0x2b18f9)[_0x9f74('0x23')](handleEntityNotFound(_0x5b56a,null))[_0x9f74('0x23')](function(_0x19ff30){if(_0x19ff30){var _0x379757=_0x19ff30[_0x9f74('0x24')]({'plain':!![]});_0x379757=qs[_0x9f74('0x4e')](_0x379757,['id',_0x9f74('0x4f'),_0x9f74('0x50')]);_0x3478b2[_0x9f74('0x51')]=_[_0x9f74('0x4e')](_0x3478b2[_0x9f74('0x51')],['id','createdAt',_0x9f74('0x50')]);return db[_0x9f74('0x3e')][_0x9f74('0x46')](_[_0x9f74('0x3b')](_0x379757,_0x3478b2[_0x9f74('0x51')]),{'include':_0x3478b2['query'][_0x9f74('0x3d')]?[{'all':!![]}]:undefined})[_0x9f74('0x23')](function(_0x33f0d1){var _0x1d3814=_0x3478b2[_0x9f74('0x47')]['get']({'plain':!![]});if(!_0x1d3814)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x1d3814[_0x9f74('0x48')]===_0x9f74('0x47')){var _0x2e344b=_0x33f0d1[_0x9f74('0x24')]({'plain':!![]});var _0x2b46b5='Projects';return db[_0x9f74('0x52')][_0x9f74('0x45')]({'where':{'name':_0x2b46b5,'userProfileId':_0x1d3814[_0x9f74('0x49')]},'raw':!![]})['then'](function(_0x1fdb14){if(_0x1fdb14&&_0x1fdb14[_0x9f74('0x4a')]===0x0){return db[_0x9f74('0x26')][_0x9f74('0x46')]({'name':_0x2e344b[_0x9f74('0x28')],'resourceId':_0x2e344b['id'],'type':_0x1fdb14[_0x9f74('0x28')],'sectionId':_0x1fdb14['id']},{})[_0x9f74('0x23')](function(){return _0x33f0d1;});}else{return _0x33f0d1;}})[_0x9f74('0x4b')](function(_0x36c4c7){logger[_0x9f74('0x27')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x36c4c7);throw _0x36c4c7;});}return _0x33f0d1;});}})[_0x9f74('0x23')](respondWithResult(_0x5b56a,0xc9))[_0x9f74('0x4b')](handleError(_0x5b56a,null));};exports[_0x9f74('0x21')]=function(_0xcb71b0,_0x264214){if(_0xcb71b0['body']['id']){delete _0xcb71b0[_0x9f74('0x51')]['id'];}return db['JscriptyProject'][_0x9f74('0x45')]({'where':{'id':_0xcb71b0[_0x9f74('0x42')]['id']}})[_0x9f74('0x23')](handleEntityNotFound(_0x264214,null))[_0x9f74('0x23')](saveUpdates(_0xcb71b0[_0x9f74('0x51')],null))[_0x9f74('0x23')](respondWithResult(_0x264214,null))[_0x9f74('0x4b')](handleError(_0x264214,null));};exports[_0x9f74('0x22')]=function(_0x466793,_0x31f5b1){return db[_0x9f74('0x3e')]['find']({'where':{'id':_0x466793[_0x9f74('0x42')]['id']}})['then'](handleEntityNotFound(_0x31f5b1,null))[_0x9f74('0x23')](removeEntity(_0x31f5b1,null))[_0x9f74('0x4b')](handleError(_0x31f5b1,null));};exports[_0x9f74('0x53')]=function(_0x57e0c1,_0x3fe446,_0x29f67e){var _0x2b92f1={'raw':!![],'where':{}};var _0x1c90d3={};var _0x1f7400={'count':0x0,'rows':[]};return db[_0x9f74('0x3e')][_0x9f74('0x54')]({'where':{'id':_0x57e0c1['params']['id']}})[_0x9f74('0x23')](handleEntityNotFound(_0x3fe446,null))['then'](function(_0x3c8c33){if(_0x3c8c33){_0x1c90d3[_0x9f74('0x2e')]=_[_0x9f74('0x43')](db[_0x9f74('0x55')][_0x9f74('0x2a')]);_0x1c90d3[_0x9f74('0x30')]=_[_0x9f74('0x43')](_0x57e0c1['query']);_0x1c90d3[_0x9f74('0x37')]=_[_0x9f74('0x31')](_0x1c90d3[_0x9f74('0x2e')],_0x1c90d3[_0x9f74('0x30')]);_0x2b92f1[_0x9f74('0x33')]=_[_0x9f74('0x31')](_0x1c90d3[_0x9f74('0x2e')],qs[_0x9f74('0x32')](_0x57e0c1['query']['fields']));_0x2b92f1[_0x9f74('0x33')]=_0x2b92f1['attributes']['length']?_0x2b92f1[_0x9f74('0x33')]:_0x1c90d3['model'];if(!_0x57e0c1[_0x9f74('0x30')][_0x9f74('0x34')](_0x9f74('0x56'))){_0x2b92f1[_0x9f74('0x1c')]=qs[_0x9f74('0x1c')](_0x57e0c1['query'][_0x9f74('0x1c')]);_0x2b92f1[_0x9f74('0x1b')]=qs[_0x9f74('0x1b')](_0x57e0c1[_0x9f74('0x30')][_0x9f74('0x1b')]);}_0x2b92f1[_0x9f74('0x35')]=qs[_0x9f74('0x36')](_0x57e0c1[_0x9f74('0x30')][_0x9f74('0x36')]);_0x2b92f1['where']=qs['filters'](_[_0x9f74('0x38')](_0x57e0c1['query'],_0x1c90d3[_0x9f74('0x37')]));_0x2b92f1['where']['ProjectId']=_0x3c8c33['id'];if(_0x57e0c1['query'][_0x9f74('0x39')]){_0x2b92f1[_0x9f74('0x3a')]=_[_0x9f74('0x3b')](_0x2b92f1[_0x9f74('0x3a')],{'$or':_[_0x9f74('0x2f')](_0x2b92f1[_0x9f74('0x33')],function(_0x5d865a){var _0x419be5={};_0x419be5[_0x5d865a]={'$like':'%'+_0x57e0c1[_0x9f74('0x30')][_0x9f74('0x39')]+'%'};return _0x419be5;})});}_0x2b92f1=_['merge']({},_0x2b92f1,_0x57e0c1[_0x9f74('0x3c')]);return db['JscriptySessionReport'][_0x9f74('0x1a')]({'where':_0x2b92f1[_0x9f74('0x3a')]})['then'](function(_0x4272ad){_0x1f7400['count']=_0x4272ad;if(_0x57e0c1['query'][_0x9f74('0x3d')]){_0x2b92f1[_0x9f74('0x44')]=[{'all':!![]}];}return db[_0x9f74('0x55')]['findAll'](_0x2b92f1);})['then'](function(_0x2551c5){_0x1f7400[_0x9f74('0x40')]=_0x2551c5;return _0x1f7400;});}})[_0x9f74('0x23')](respondWithFilteredResult(_0x3fe446,_0x2b92f1))['catch'](handleError(_0x3fe446,null));};exports['getAnswers']=function(_0x5008fb,_0x4f1222,_0x427296){var _0x1b9345={'raw':!![],'where':{}};var _0x38d78d={};var _0x58f833={'count':0x0,'rows':[]};return db[_0x9f74('0x3e')][_0x9f74('0x54')]({'where':{'id':_0x5008fb[_0x9f74('0x42')]['id']}})[_0x9f74('0x23')](handleEntityNotFound(_0x4f1222,null))['then'](function(_0x11d4f7){if(_0x11d4f7){_0x38d78d[_0x9f74('0x2e')]=_[_0x9f74('0x43')](db[_0x9f74('0x57')][_0x9f74('0x2a')]);_0x38d78d[_0x9f74('0x30')]=_['keys'](_0x5008fb[_0x9f74('0x30')]);_0x38d78d[_0x9f74('0x37')]=_[_0x9f74('0x31')](_0x38d78d[_0x9f74('0x2e')],_0x38d78d[_0x9f74('0x30')]);_0x1b9345[_0x9f74('0x33')]=_[_0x9f74('0x31')](_0x38d78d[_0x9f74('0x2e')],qs[_0x9f74('0x32')](_0x5008fb[_0x9f74('0x30')]['fields']));_0x1b9345[_0x9f74('0x33')]=_0x1b9345[_0x9f74('0x33')][_0x9f74('0x4d')]?_0x1b9345[_0x9f74('0x33')]:_0x38d78d[_0x9f74('0x2e')];if(!_0x5008fb[_0x9f74('0x30')][_0x9f74('0x34')](_0x9f74('0x56'))){_0x1b9345['limit']=qs[_0x9f74('0x1c')](_0x5008fb['query'][_0x9f74('0x1c')]);_0x1b9345[_0x9f74('0x1b')]=qs[_0x9f74('0x1b')](_0x5008fb[_0x9f74('0x30')][_0x9f74('0x1b')]);}_0x1b9345['order']=qs[_0x9f74('0x36')](_0x5008fb[_0x9f74('0x30')]['sort']);_0x1b9345[_0x9f74('0x3a')]=qs['filters'](_[_0x9f74('0x38')](_0x5008fb['query'],_0x38d78d['filters']));_0x1b9345[_0x9f74('0x3a')]['ProjectId']=_0x11d4f7['id'];if(_0x5008fb[_0x9f74('0x30')][_0x9f74('0x39')]){_0x1b9345[_0x9f74('0x3a')]=_['merge'](_0x1b9345[_0x9f74('0x3a')],{'$or':_[_0x9f74('0x2f')](_0x1b9345[_0x9f74('0x33')],function(_0x3cfbed){var _0xba4dc={};_0xba4dc[_0x3cfbed]={'$like':'%'+_0x5008fb[_0x9f74('0x30')][_0x9f74('0x39')]+'%'};return _0xba4dc;})});}_0x1b9345=_['merge']({},_0x1b9345,_0x5008fb[_0x9f74('0x3c')]);return db[_0x9f74('0x57')]['count']({'where':_0x1b9345[_0x9f74('0x3a')]})[_0x9f74('0x23')](function(_0x1ac09e){_0x58f833[_0x9f74('0x1a')]=_0x1ac09e;if(_0x5008fb[_0x9f74('0x30')][_0x9f74('0x3d')]){_0x1b9345[_0x9f74('0x44')]=[{'all':!![]}];}return db[_0x9f74('0x57')][_0x9f74('0x3f')](_0x1b9345);})[_0x9f74('0x23')](function(_0x2fde96){_0x58f833[_0x9f74('0x40')]=_0x2fde96;return _0x58f833;});}})[_0x9f74('0x23')](respondWithFilteredResult(_0x4f1222,_0x1b9345))[_0x9f74('0x4b')](handleError(_0x4f1222,null));};function char(_0xb93015){return _0x9f74('0x58')===typeof _0xb93015?String[_0x9f74('0x59')][_0x9f74('0x1f')](null,arguments):_0xb93015;}function needsEncapsulation(_0x11e96e){return!!_0x11e96e&&(_0x11e96e[_0x9f74('0x5a')]()[_0x9f74('0x5b')](char(0xd))>=0x0||_0x11e96e[_0x9f74('0x5a')]()['indexOf'](char(0xa))>=0x0||_0x11e96e[_0x9f74('0x5a')]()['indexOf'](char(0x2c))>=0x0||_0x11e96e['toString']()[_0x9f74('0x5b')](char(0x22))>=0x0);}function encapsulate(_0x59bb72){var _0x8334d6=char(0x22),_0x29e0dc='\x5c'+char(0x22),_0x275c34=_0x59bb72['toString']()[_0x9f74('0x5c')](new RegExp(_0x8334d6,'g'),_0x29e0dc);return _0x8334d6+_0x275c34+_0x8334d6;}exports[_0x9f74('0x5d')]=function(_0x45cac3,_0x4f8ec5,_0x239e41){var _0x57304b,_0x51409e;var _0x5afe95={'where':{'ProjectId':_0x45cac3[_0x9f74('0x42')]['id']}};if(_0x45cac3[_0x9f74('0x30')][_0x9f74('0x5e')]){_0x5afe95[_0x9f74('0x3a')][_0x9f74('0x5f')]=JSON[_0x9f74('0x60')](_0x45cac3['query'][_0x9f74('0x5e')]);}return db['JscriptySessionReport'][_0x9f74('0x3f')](_0x5afe95)[_0x9f74('0x23')](handleEntityNotFound(_0x4f8ec5,null))['then'](function(_0x13bc3b){if(_0x13bc3b){_0x57304b=_0x13bc3b;return db[_0x9f74('0x61')]['findAll']({'where':{'SessionId':{'$in':_[_0x9f74('0x2f')](_0x57304b,'id')},'ProjectId':_0x45cac3[_0x9f74('0x42')]['id']},'order':_0x9f74('0x62')});}})[_0x9f74('0x23')](handleEntityNotFound(_0x4f8ec5,null))[_0x9f74('0x23')](function(_0x39b913){if(_0x39b913){_0x51409e=_0x39b913;var _0x1cd70a={};for(var _0x5bd726=0x0,_0x49e276=_0x51409e[_0x9f74('0x4d')];_0x5bd726<_0x49e276;_0x5bd726++){if(!_0x1cd70a[_0x9f74('0x34')](_0x51409e[_0x5bd726]['questionId'])){_0x1cd70a[_0x51409e[_0x5bd726][_0x9f74('0x63')]]=needsEncapsulation(_0x51409e[_0x5bd726]['question'])?encapsulate(_0x51409e[_0x5bd726][_0x9f74('0x64')]):_0x51409e[_0x5bd726][_0x9f74('0x64')];}}var _0x12ea5a=[],_0x3ab1a2={};for(var _0x2a95fe=0x0,_0x34e070=_0x57304b[_0x9f74('0x4d')];_0x2a95fe<_0x34e070;_0x2a95fe++){_0x3ab1a2={'ProjectId':_0x45cac3['params']['id'],'SessionId':_0x57304b[_0x2a95fe]['id'],'StartTime':moment(_0x57304b[_0x2a95fe][_0x9f74('0x5f')])[_0x9f74('0x65')]('YYYY-MM-DD\x20HH:mm:ss')};for(var _0x54a605=0x0,_0x341a14=_0x51409e[_0x9f74('0x4d')];_0x54a605<_0x341a14;_0x54a605++){if(_0x51409e[_0x54a605][_0x9f74('0x66')]==_0x57304b[_0x2a95fe]['id']&&_0x1cd70a[_0x9f74('0x34')](_0x51409e[_0x54a605][_0x9f74('0x63')])){_0x3ab1a2[_0x1cd70a[_0x51409e[_0x54a605]['questionId']]]=_0x51409e[_0x54a605][_0x9f74('0x67')];}}for(var _0x4d1c49 in _0x1cd70a){if(!_0x3ab1a2[_0x9f74('0x34')](_0x1cd70a[_0x4d1c49])){_0x3ab1a2[_0x1cd70a[_0x4d1c49]]=null;}}_0x12ea5a[_0x9f74('0x68')](_0x3ab1a2);}return _0x12ea5a;}})['then'](function(_0x5b005d){if(!_[_0x9f74('0x69')](_0x5b005d)){var _0x2f8ee3=toCsv(_0x5b005d);var _0x48c293=Date[_0x9f74('0x6a')]();fs[_0x9f74('0x6b')](util['format'](_0x9f74('0x6c'),_0x45cac3[_0x9f74('0x42')]['id'],_0x48c293),_0x2f8ee3);_0x4f8ec5[_0x9f74('0x6d')]('Content-disposition',_0x9f74('0x6e')+util[_0x9f74('0x65')](_0x9f74('0x6f'),_0x45cac3[_0x9f74('0x42')]['id'],_0x48c293));_0x4f8ec5[_0x9f74('0x6d')](_0x9f74('0x70'),_0x9f74('0x71'));return _0x4f8ec5[_0x9f74('0x72')](util['format'](_0x9f74('0x6c'),_0x45cac3[_0x9f74('0x42')]['id'],_0x48c293));}else{return _0x4f8ec5['sendStatus'](0xcc);}})[_0x9f74('0x4b')](handleError(_0x4f8ec5,null));};
\ No newline at end of file
+var _0x58cc=['attachment;\x20filename=','Jscripty_Project_%d_Summary_%s.csv','text/csv','download','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','squel','crypto','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','then','destroy','get','Projects','UserProfileResource','error','stack','name','send','map','JscriptyProject','rawAttributes','fieldName','type','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','include','findAll','catch','show','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','params','updatedAt','createdAt','role','update','getSessions','findOne','JscriptySessionReport','ProjectId','rows','getAnswers','JscriptyAnswerReport','number','fromCharCode','toString','indexOf','replace','getSummary','startTime','starttime','questionId','question','format','YYYY-MM-DD\x20HH:mm:ss','answer','push','now','writeFileSync','/tmp/Jscripty_Project_%d_Summary_%s.csv','setHeader','Content-disposition'];(function(_0x4057ba,_0x380a53){var _0xd88410=function(_0x39a564){while(--_0x39a564){_0x4057ba['push'](_0x4057ba['shift']());}};_0xd88410(++_0x380a53);}(_0x58cc,0x7a));var _0xc58c=function(_0x4b174a,_0x33a017){_0x4b174a=_0x4b174a-0x0;var _0x3cd7bf=_0x58cc[_0x4b174a];return _0x3cd7bf;};'use strict';var emlformat=require(_0xc58c('0x0'));var rimraf=require(_0xc58c('0x1'));var zipdir=require(_0xc58c('0x2'));var jsonpatch=require(_0xc58c('0x3'));var rp=require(_0xc58c('0x4'));var moment=require(_0xc58c('0x5'));var BPromise=require('bluebird');var Mustache=require(_0xc58c('0x6'));var util=require(_0xc58c('0x7'));var path=require(_0xc58c('0x8'));var sox=require(_0xc58c('0x9'));var csv=require(_0xc58c('0xa'));var ejs=require(_0xc58c('0xb'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xc58c('0xc'));var crypto=require(_0xc58c('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xc58c('0xe'));var toCsv=require(_0xc58c('0xa'));var querystring=require('querystring');var Papa=require(_0xc58c('0xf'));var Redis=require('ioredis');var authService=require(_0xc58c('0x10'));var qs=require(_0xc58c('0x11'));var as=require(_0xc58c('0x12'));var hardwareService=require(_0xc58c('0x13'));var logger=require(_0xc58c('0x14'))(_0xc58c('0x15'));var utils=require('../../config/utils');var config=require(_0xc58c('0x16'));var licenseUtil=require(_0xc58c('0x17'));var db=require(_0xc58c('0x18'))['db'];function respondWithStatusCode(_0x376bbb,_0x311dc2){_0x311dc2=_0x311dc2||0xcc;return function(_0x41ed49){if(_0x41ed49){return _0x376bbb[_0xc58c('0x19')](_0x311dc2);}return _0x376bbb[_0xc58c('0x1a')](_0x311dc2)[_0xc58c('0x1b')]();};}function respondWithResult(_0x4638d1,_0x499235){_0x499235=_0x499235||0xc8;return function(_0x233b9c){if(_0x233b9c){return _0x4638d1['status'](_0x499235)[_0xc58c('0x1c')](_0x233b9c);}};}function respondWithFilteredResult(_0x2086a2,_0x3dfff5){return function(_0x313849){if(_0x313849){var _0xa6b37a=typeof _0x3dfff5[_0xc58c('0x1d')]===_0xc58c('0x1e')&&typeof _0x3dfff5[_0xc58c('0x1f')]===_0xc58c('0x1e');var _0x30badc=_0x313849[_0xc58c('0x20')];var _0x4a9536=_0xa6b37a?0x0:_0x3dfff5[_0xc58c('0x1d')];var _0x475711=_0xa6b37a?_0x313849[_0xc58c('0x20')]:_0x3dfff5[_0xc58c('0x1d')]+_0x3dfff5['limit'];var _0x43e650;if(_0x475711>=_0x30badc){_0x475711=_0x30badc;_0x43e650=0xc8;}else{_0x43e650=0xce;}_0x2086a2[_0xc58c('0x1a')](_0x43e650);return _0x2086a2[_0xc58c('0x21')]('Content-Range',_0x4a9536+'-'+_0x475711+'/'+_0x30badc)['json'](_0x313849);}return null;};}function patchUpdates(_0x545e8e){return function(_0xcf3d26){try{jsonpatch[_0xc58c('0x22')](_0xcf3d26,_0x545e8e,!![]);}catch(_0xae79a1){return BPromise[_0xc58c('0x23')](_0xae79a1);}return _0xcf3d26['save']();};}function saveUpdates(_0x48444f,_0x16ba3f){return function(_0x284f0e){if(_0x284f0e){return _0x284f0e['update'](_0x48444f)[_0xc58c('0x24')](function(_0x295b26){return _0x295b26;});}return null;};}function removeEntity(_0x1e3f82,_0x586743){return function(_0x4eb13a){if(_0x4eb13a){return _0x4eb13a[_0xc58c('0x25')]()[_0xc58c('0x24')](function(){var _0x2a529e=_0x4eb13a[_0xc58c('0x26')]({'plain':!![]});var _0x5a66d8=_0xc58c('0x27');return db[_0xc58c('0x28')][_0xc58c('0x25')]({'where':{'type':_0x5a66d8,'resourceId':_0x2a529e['id']}})[_0xc58c('0x24')](function(){return _0x4eb13a;});})[_0xc58c('0x24')](function(){_0x1e3f82[_0xc58c('0x1a')](0xcc)[_0xc58c('0x1b')]();});}};}function handleEntityNotFound(_0x34bcfb,_0x4d6ae4){return function(_0x161c6f){if(!_0x161c6f){_0x34bcfb[_0xc58c('0x19')](0x194);}return _0x161c6f;};}function handleError(_0x402e57,_0x585110){_0x585110=_0x585110||0x1f4;return function(_0x3dd9cc){logger[_0xc58c('0x29')](_0x3dd9cc[_0xc58c('0x2a')]);if(_0x3dd9cc[_0xc58c('0x2b')]){delete _0x3dd9cc['name'];}_0x402e57[_0xc58c('0x1a')](_0x585110)[_0xc58c('0x2c')](_0x3dd9cc);};}exports['index']=function(_0xb62ba5,_0x2c0d29){var _0x521a1a={},_0x16461c={},_0x424cc8={'count':0x0,'rows':[]};var _0x4257ef=_[_0xc58c('0x2d')](db[_0xc58c('0x2e')][_0xc58c('0x2f')],function(_0x1077d5){return{'name':_0x1077d5[_0xc58c('0x30')],'type':_0x1077d5[_0xc58c('0x31')]['key']};});_0x16461c[_0xc58c('0x32')]=_[_0xc58c('0x2d')](_0x4257ef,_0xc58c('0x2b'));_0x16461c[_0xc58c('0x33')]=_[_0xc58c('0x34')](_0xb62ba5[_0xc58c('0x33')]);_0x16461c[_0xc58c('0x35')]=_[_0xc58c('0x36')](_0x16461c['model'],_0x16461c[_0xc58c('0x33')]);_0x521a1a[_0xc58c('0x37')]=_[_0xc58c('0x36')](_0x16461c[_0xc58c('0x32')],qs[_0xc58c('0x38')](_0xb62ba5[_0xc58c('0x33')]['fields']));_0x521a1a[_0xc58c('0x37')]=_0x521a1a[_0xc58c('0x37')][_0xc58c('0x39')]?_0x521a1a[_0xc58c('0x37')]:_0x16461c[_0xc58c('0x32')];if(!_0xb62ba5['query'][_0xc58c('0x3a')](_0xc58c('0x3b'))){_0x521a1a[_0xc58c('0x1f')]=qs[_0xc58c('0x1f')](_0xb62ba5[_0xc58c('0x33')][_0xc58c('0x1f')]);_0x521a1a[_0xc58c('0x1d')]=qs[_0xc58c('0x1d')](_0xb62ba5[_0xc58c('0x33')][_0xc58c('0x1d')]);}_0x521a1a[_0xc58c('0x3c')]=qs[_0xc58c('0x3d')](_0xb62ba5[_0xc58c('0x33')][_0xc58c('0x3d')]);_0x521a1a[_0xc58c('0x3e')]=qs[_0xc58c('0x35')](_[_0xc58c('0x3f')](_0xb62ba5[_0xc58c('0x33')],_0x16461c[_0xc58c('0x35')]),_0x4257ef);if(_0xb62ba5[_0xc58c('0x33')][_0xc58c('0x40')]){_0x521a1a['where']=_['merge'](_0x521a1a['where'],{'$or':_[_0xc58c('0x2d')](_0x4257ef,function(_0x458b69){if(_0x458b69['type']!==_0xc58c('0x41')){var _0x1b9511={};_0x1b9511[_0x458b69['name']]={'$like':'%'+_0xb62ba5[_0xc58c('0x33')][_0xc58c('0x40')]+'%'};return _0x1b9511;}})});}_0x521a1a=_[_0xc58c('0x42')]({},_0x521a1a,_0xb62ba5[_0xc58c('0x43')]);var _0x47676e={'where':_0x521a1a[_0xc58c('0x3e')]};return db[_0xc58c('0x2e')][_0xc58c('0x20')](_0x47676e)[_0xc58c('0x24')](function(_0x21dea0){_0x424cc8['count']=_0x21dea0;if(_0xb62ba5[_0xc58c('0x33')]['includeAll']){_0x521a1a[_0xc58c('0x44')]=[{'all':!![]}];}return db[_0xc58c('0x2e')][_0xc58c('0x45')](_0x521a1a);})[_0xc58c('0x24')](function(_0x14f66b){_0x424cc8['rows']=_0x14f66b;return _0x424cc8;})[_0xc58c('0x24')](respondWithFilteredResult(_0x2c0d29,_0x521a1a))[_0xc58c('0x46')](handleError(_0x2c0d29,null));};exports[_0xc58c('0x47')]=function(_0x312333,_0x4f571a){var _0x583143={'raw':![],'where':{'id':_0x312333['params']['id']}},_0xf87434={};_0xf87434[_0xc58c('0x32')]=_['keys'](db[_0xc58c('0x2e')][_0xc58c('0x2f')]);_0xf87434[_0xc58c('0x33')]=_[_0xc58c('0x34')](_0x312333[_0xc58c('0x33')]);_0xf87434[_0xc58c('0x35')]=_[_0xc58c('0x36')](_0xf87434[_0xc58c('0x32')],_0xf87434[_0xc58c('0x33')]);_0x583143[_0xc58c('0x37')]=_[_0xc58c('0x36')](_0xf87434[_0xc58c('0x32')],qs[_0xc58c('0x38')](_0x312333[_0xc58c('0x33')]['fields']));_0x583143['attributes']=_0x583143[_0xc58c('0x37')][_0xc58c('0x39')]?_0x583143[_0xc58c('0x37')]:_0xf87434[_0xc58c('0x32')];if(_0x312333[_0xc58c('0x33')][_0xc58c('0x48')]){_0x583143[_0xc58c('0x44')]=[{'all':!![]}];}_0x583143=_[_0xc58c('0x42')]({},_0x583143,_0x312333[_0xc58c('0x43')]);return db[_0xc58c('0x2e')][_0xc58c('0x49')](_0x583143)[_0xc58c('0x24')](handleEntityNotFound(_0x4f571a,null))[_0xc58c('0x24')](respondWithResult(_0x4f571a,null))[_0xc58c('0x46')](handleError(_0x4f571a,null));};exports['create']=function(_0xe59c30,_0x27b336){return db[_0xc58c('0x2e')][_0xc58c('0x4a')](_0xe59c30[_0xc58c('0x4b')],{})[_0xc58c('0x24')](function(_0xaf8626){var _0x4d1e4f=_0xe59c30[_0xc58c('0x4c')]['get']({'plain':!![]});if(!_0x4d1e4f)throw new Error(_0xc58c('0x4d'));if(_0x4d1e4f['role']===_0xc58c('0x4c')){var _0x336411=_0xaf8626[_0xc58c('0x26')]({'plain':!![]});var _0x4ca991='Projects';return db[_0xc58c('0x4e')][_0xc58c('0x49')]({'where':{'name':_0x4ca991,'userProfileId':_0x4d1e4f[_0xc58c('0x4f')]},'raw':!![]})[_0xc58c('0x24')](function(_0x291fbd){if(_0x291fbd&&_0x291fbd[_0xc58c('0x50')]===0x0){return db[_0xc58c('0x28')][_0xc58c('0x4a')]({'name':_0x336411[_0xc58c('0x2b')],'resourceId':_0x336411['id'],'type':_0x291fbd[_0xc58c('0x2b')],'sectionId':_0x291fbd['id']},{})['then'](function(){return _0xaf8626;});}else{return _0xaf8626;}})['catch'](function(_0x4a2e2e){logger[_0xc58c('0x29')](_0xc58c('0x51'),_0x4a2e2e);throw _0x4a2e2e;});}return _0xaf8626;})['then'](respondWithResult(_0x27b336,0xc9))['catch'](handleError(_0x27b336,null));};exports[_0xc58c('0x52')]=function(_0x175123,_0x57fddc){var _0x57d8b2={'where':{'id':_0x175123[_0xc58c('0x53')]['id']}},_0x3f7f59={};_0x3f7f59['model']=_[_0xc58c('0x34')](db[_0xc58c('0x2e')][_0xc58c('0x2f')]);_0x57d8b2[_0xc58c('0x37')]=_[_0xc58c('0x36')](_0x3f7f59[_0xc58c('0x32')],qs['fields'](_0x175123['query']['fields']));_0x57d8b2['attributes']=_0x57d8b2[_0xc58c('0x37')]['length']?_0x57d8b2[_0xc58c('0x37')]:_0x3f7f59[_0xc58c('0x32')];if(_0x175123['query'][_0xc58c('0x48')]){_0x57d8b2['include']=[{'all':!![]}];}_0x57d8b2=_[_0xc58c('0x42')]({},_0x57d8b2,_0x175123[_0xc58c('0x43')]);return db[_0xc58c('0x2e')][_0xc58c('0x49')](_0x57d8b2)['then'](handleEntityNotFound(_0x57fddc,null))[_0xc58c('0x24')](function(_0x37ab27){if(_0x37ab27){var _0x1a140d=_0x37ab27[_0xc58c('0x26')]({'plain':!![]});_0x1a140d=qs['omit'](_0x1a140d,['id','createdAt',_0xc58c('0x54')]);_0x175123[_0xc58c('0x4b')]=_['omit'](_0x175123[_0xc58c('0x4b')],['id',_0xc58c('0x55'),_0xc58c('0x54')]);return db['JscriptyProject'][_0xc58c('0x4a')](_[_0xc58c('0x42')](_0x1a140d,_0x175123[_0xc58c('0x4b')]),{'include':_0x175123[_0xc58c('0x33')][_0xc58c('0x48')]?[{'all':!![]}]:undefined})[_0xc58c('0x24')](function(_0x5cc414){var _0x130a14=_0x175123['user'][_0xc58c('0x26')]({'plain':!![]});if(!_0x130a14)throw new Error(_0xc58c('0x4d'));if(_0x130a14[_0xc58c('0x56')]===_0xc58c('0x4c')){var _0xec1b7e=_0x5cc414['get']({'plain':!![]});var _0x5ac00c=_0xc58c('0x27');return db[_0xc58c('0x4e')]['find']({'where':{'name':_0x5ac00c,'userProfileId':_0x130a14[_0xc58c('0x4f')]},'raw':!![]})[_0xc58c('0x24')](function(_0xc3d85f){if(_0xc3d85f&&_0xc3d85f[_0xc58c('0x50')]===0x0){return db[_0xc58c('0x28')][_0xc58c('0x4a')]({'name':_0xec1b7e['name'],'resourceId':_0xec1b7e['id'],'type':_0xc3d85f['name'],'sectionId':_0xc3d85f['id']},{})[_0xc58c('0x24')](function(){return _0x5cc414;});}else{return _0x5cc414;}})[_0xc58c('0x46')](function(_0x2d2248){logger[_0xc58c('0x29')](_0xc58c('0x51'),_0x2d2248);throw _0x2d2248;});}return _0x5cc414;});}})[_0xc58c('0x24')](respondWithResult(_0x57fddc,0xc9))['catch'](handleError(_0x57fddc,null));};exports[_0xc58c('0x57')]=function(_0xf94c2f,_0x2559e6){if(_0xf94c2f['body']['id']){delete _0xf94c2f['body']['id'];}return db['JscriptyProject'][_0xc58c('0x49')]({'where':{'id':_0xf94c2f[_0xc58c('0x53')]['id']}})['then'](handleEntityNotFound(_0x2559e6,null))[_0xc58c('0x24')](saveUpdates(_0xf94c2f['body'],null))['then'](respondWithResult(_0x2559e6,null))[_0xc58c('0x46')](handleError(_0x2559e6,null));};exports[_0xc58c('0x25')]=function(_0x3ea2c4,_0x1a4353){return db[_0xc58c('0x2e')][_0xc58c('0x49')]({'where':{'id':_0x3ea2c4[_0xc58c('0x53')]['id']}})['then'](handleEntityNotFound(_0x1a4353,null))['then'](removeEntity(_0x1a4353,null))[_0xc58c('0x46')](handleError(_0x1a4353,null));};exports[_0xc58c('0x58')]=function(_0x1f7c01,_0x269b37,_0x2aa25f){var _0xd8ffd2={'raw':!![],'where':{}};var _0x22e994={};var _0x46c688={'count':0x0,'rows':[]};return db[_0xc58c('0x2e')][_0xc58c('0x59')]({'where':{'id':_0x1f7c01[_0xc58c('0x53')]['id']}})[_0xc58c('0x24')](handleEntityNotFound(_0x269b37,null))[_0xc58c('0x24')](function(_0x37d6b8){if(_0x37d6b8){_0x22e994[_0xc58c('0x32')]=_[_0xc58c('0x34')](db[_0xc58c('0x5a')][_0xc58c('0x2f')]);_0x22e994[_0xc58c('0x33')]=_[_0xc58c('0x34')](_0x1f7c01['query']);_0x22e994[_0xc58c('0x35')]=_[_0xc58c('0x36')](_0x22e994[_0xc58c('0x32')],_0x22e994[_0xc58c('0x33')]);_0xd8ffd2[_0xc58c('0x37')]=_['intersection'](_0x22e994['model'],qs[_0xc58c('0x38')](_0x1f7c01[_0xc58c('0x33')][_0xc58c('0x38')]));_0xd8ffd2['attributes']=_0xd8ffd2['attributes'][_0xc58c('0x39')]?_0xd8ffd2[_0xc58c('0x37')]:_0x22e994[_0xc58c('0x32')];if(!_0x1f7c01[_0xc58c('0x33')][_0xc58c('0x3a')](_0xc58c('0x3b'))){_0xd8ffd2[_0xc58c('0x1f')]=qs[_0xc58c('0x1f')](_0x1f7c01[_0xc58c('0x33')][_0xc58c('0x1f')]);_0xd8ffd2[_0xc58c('0x1d')]=qs['offset'](_0x1f7c01[_0xc58c('0x33')][_0xc58c('0x1d')]);}_0xd8ffd2[_0xc58c('0x3c')]=qs[_0xc58c('0x3d')](_0x1f7c01[_0xc58c('0x33')][_0xc58c('0x3d')]);_0xd8ffd2[_0xc58c('0x3e')]=qs[_0xc58c('0x35')](_['pick'](_0x1f7c01[_0xc58c('0x33')],_0x22e994['filters']));_0xd8ffd2[_0xc58c('0x3e')][_0xc58c('0x5b')]=_0x37d6b8['id'];if(_0x1f7c01[_0xc58c('0x33')][_0xc58c('0x40')]){_0xd8ffd2[_0xc58c('0x3e')]=_['merge'](_0xd8ffd2[_0xc58c('0x3e')],{'$or':_['map'](_0xd8ffd2[_0xc58c('0x37')],function(_0x27778c){var _0x476bd6={};_0x476bd6[_0x27778c]={'$like':'%'+_0x1f7c01[_0xc58c('0x33')][_0xc58c('0x40')]+'%'};return _0x476bd6;})});}_0xd8ffd2=_['merge']({},_0xd8ffd2,_0x1f7c01[_0xc58c('0x43')]);return db[_0xc58c('0x5a')]['count']({'where':_0xd8ffd2[_0xc58c('0x3e')]})[_0xc58c('0x24')](function(_0x460d59){_0x46c688[_0xc58c('0x20')]=_0x460d59;if(_0x1f7c01[_0xc58c('0x33')][_0xc58c('0x48')]){_0xd8ffd2[_0xc58c('0x44')]=[{'all':!![]}];}return db['JscriptySessionReport'][_0xc58c('0x45')](_0xd8ffd2);})[_0xc58c('0x24')](function(_0x3bdd68){_0x46c688[_0xc58c('0x5c')]=_0x3bdd68;return _0x46c688;});}})[_0xc58c('0x24')](respondWithFilteredResult(_0x269b37,_0xd8ffd2))[_0xc58c('0x46')](handleError(_0x269b37,null));};exports[_0xc58c('0x5d')]=function(_0x4ec036,_0x4fc8cb,_0x542566){var _0x143295={'raw':!![],'where':{}};var _0x48e568={};var _0x59fe80={'count':0x0,'rows':[]};return db[_0xc58c('0x2e')][_0xc58c('0x59')]({'where':{'id':_0x4ec036['params']['id']}})['then'](handleEntityNotFound(_0x4fc8cb,null))[_0xc58c('0x24')](function(_0x5d591e){if(_0x5d591e){_0x48e568[_0xc58c('0x32')]=_[_0xc58c('0x34')](db[_0xc58c('0x5e')][_0xc58c('0x2f')]);_0x48e568[_0xc58c('0x33')]=_[_0xc58c('0x34')](_0x4ec036[_0xc58c('0x33')]);_0x48e568['filters']=_[_0xc58c('0x36')](_0x48e568[_0xc58c('0x32')],_0x48e568[_0xc58c('0x33')]);_0x143295[_0xc58c('0x37')]=_[_0xc58c('0x36')](_0x48e568[_0xc58c('0x32')],qs[_0xc58c('0x38')](_0x4ec036[_0xc58c('0x33')][_0xc58c('0x38')]));_0x143295[_0xc58c('0x37')]=_0x143295[_0xc58c('0x37')][_0xc58c('0x39')]?_0x143295['attributes']:_0x48e568[_0xc58c('0x32')];if(!_0x4ec036['query'][_0xc58c('0x3a')](_0xc58c('0x3b'))){_0x143295[_0xc58c('0x1f')]=qs['limit'](_0x4ec036['query'][_0xc58c('0x1f')]);_0x143295[_0xc58c('0x1d')]=qs[_0xc58c('0x1d')](_0x4ec036['query']['offset']);}_0x143295[_0xc58c('0x3c')]=qs[_0xc58c('0x3d')](_0x4ec036[_0xc58c('0x33')][_0xc58c('0x3d')]);_0x143295[_0xc58c('0x3e')]=qs[_0xc58c('0x35')](_[_0xc58c('0x3f')](_0x4ec036[_0xc58c('0x33')],_0x48e568[_0xc58c('0x35')]));_0x143295[_0xc58c('0x3e')][_0xc58c('0x5b')]=_0x5d591e['id'];if(_0x4ec036['query']['filter']){_0x143295[_0xc58c('0x3e')]=_[_0xc58c('0x42')](_0x143295[_0xc58c('0x3e')],{'$or':_['map'](_0x143295[_0xc58c('0x37')],function(_0x57d623){var _0x424264={};_0x424264[_0x57d623]={'$like':'%'+_0x4ec036[_0xc58c('0x33')][_0xc58c('0x40')]+'%'};return _0x424264;})});}_0x143295=_[_0xc58c('0x42')]({},_0x143295,_0x4ec036[_0xc58c('0x43')]);return db['JscriptyAnswerReport']['count']({'where':_0x143295[_0xc58c('0x3e')]})[_0xc58c('0x24')](function(_0x4ddab0){_0x59fe80[_0xc58c('0x20')]=_0x4ddab0;if(_0x4ec036[_0xc58c('0x33')]['includeAll']){_0x143295[_0xc58c('0x44')]=[{'all':!![]}];}return db[_0xc58c('0x5e')]['findAll'](_0x143295);})[_0xc58c('0x24')](function(_0x1b9045){_0x59fe80[_0xc58c('0x5c')]=_0x1b9045;return _0x59fe80;});}})[_0xc58c('0x24')](respondWithFilteredResult(_0x4fc8cb,_0x143295))['catch'](handleError(_0x4fc8cb,null));};function char(_0x52a2c7){return _0xc58c('0x5f')===typeof _0x52a2c7?String[_0xc58c('0x60')][_0xc58c('0x22')](null,arguments):_0x52a2c7;}function needsEncapsulation(_0x3d8823){return!!_0x3d8823&&(_0x3d8823[_0xc58c('0x61')]()[_0xc58c('0x62')](char(0xd))>=0x0||_0x3d8823[_0xc58c('0x61')]()[_0xc58c('0x62')](char(0xa))>=0x0||_0x3d8823[_0xc58c('0x61')]()[_0xc58c('0x62')](char(0x2c))>=0x0||_0x3d8823[_0xc58c('0x61')]()[_0xc58c('0x62')](char(0x22))>=0x0);}function encapsulate(_0x438b7e){var _0x1bd694=char(0x22),_0x11d820='\x5c'+char(0x22),_0xcf0717=_0x438b7e[_0xc58c('0x61')]()[_0xc58c('0x63')](new RegExp(_0x1bd694,'g'),_0x11d820);return _0x1bd694+_0xcf0717+_0x1bd694;}exports[_0xc58c('0x64')]=function(_0x3e90c2,_0x92faba,_0x390423){var _0x146e11,_0x2dd9bf;var _0x5d4803={'where':{'ProjectId':_0x3e90c2[_0xc58c('0x53')]['id']}};if(_0x3e90c2[_0xc58c('0x33')][_0xc58c('0x65')]){_0x5d4803[_0xc58c('0x3e')][_0xc58c('0x66')]=JSON['parse'](_0x3e90c2['query'][_0xc58c('0x65')]);}return db[_0xc58c('0x5a')][_0xc58c('0x45')](_0x5d4803)[_0xc58c('0x24')](handleEntityNotFound(_0x92faba,null))[_0xc58c('0x24')](function(_0x49b7a9){if(_0x49b7a9){_0x146e11=_0x49b7a9;return db['JscriptyQuestionReport'][_0xc58c('0x45')]({'where':{'SessionId':{'$in':_['map'](_0x146e11,'id')},'ProjectId':_0x3e90c2[_0xc58c('0x53')]['id']},'order':'-createdAt'});}})[_0xc58c('0x24')](handleEntityNotFound(_0x92faba,null))[_0xc58c('0x24')](function(_0x34cf0a){if(_0x34cf0a){_0x2dd9bf=_0x34cf0a;var _0x27c62f={};for(var _0x57dfd9=0x0,_0x2325f9=_0x2dd9bf[_0xc58c('0x39')];_0x57dfd9<_0x2325f9;_0x57dfd9++){if(!_0x27c62f[_0xc58c('0x3a')](_0x2dd9bf[_0x57dfd9][_0xc58c('0x67')])){_0x27c62f[_0x2dd9bf[_0x57dfd9][_0xc58c('0x67')]]=needsEncapsulation(_0x2dd9bf[_0x57dfd9][_0xc58c('0x68')])?encapsulate(_0x2dd9bf[_0x57dfd9][_0xc58c('0x68')]):_0x2dd9bf[_0x57dfd9][_0xc58c('0x68')];}}var _0x10acdd=[],_0x16aa0b={};for(var _0x3e4771=0x0,_0x57f0bc=_0x146e11[_0xc58c('0x39')];_0x3e4771<_0x57f0bc;_0x3e4771++){_0x16aa0b={'ProjectId':_0x3e90c2['params']['id'],'SessionId':_0x146e11[_0x3e4771]['id'],'StartTime':moment(_0x146e11[_0x3e4771]['starttime'])[_0xc58c('0x69')](_0xc58c('0x6a'))};for(var _0x397e0a=0x0,_0x26be11=_0x2dd9bf['length'];_0x397e0a<_0x26be11;_0x397e0a++){if(_0x2dd9bf[_0x397e0a]['SessionId']==_0x146e11[_0x3e4771]['id']&&_0x27c62f[_0xc58c('0x3a')](_0x2dd9bf[_0x397e0a][_0xc58c('0x67')])){_0x16aa0b[_0x27c62f[_0x2dd9bf[_0x397e0a]['questionId']]]=_0x2dd9bf[_0x397e0a][_0xc58c('0x6b')];}}for(var _0x38d384 in _0x27c62f){if(!_0x16aa0b['hasOwnProperty'](_0x27c62f[_0x38d384])){_0x16aa0b[_0x27c62f[_0x38d384]]=null;}}_0x10acdd[_0xc58c('0x6c')](_0x16aa0b);}return _0x10acdd;}})[_0xc58c('0x24')](function(_0x12b390){if(!_['isEmpty'](_0x12b390)){var _0x54f0bb=toCsv(_0x12b390);var _0x5909a5=Date[_0xc58c('0x6d')]();fs[_0xc58c('0x6e')](util['format'](_0xc58c('0x6f'),_0x3e90c2[_0xc58c('0x53')]['id'],_0x5909a5),_0x54f0bb);_0x92faba[_0xc58c('0x70')](_0xc58c('0x71'),_0xc58c('0x72')+util[_0xc58c('0x69')](_0xc58c('0x73'),_0x3e90c2[_0xc58c('0x53')]['id'],_0x5909a5));_0x92faba['setHeader']('Content-type',_0xc58c('0x74'));return _0x92faba[_0xc58c('0x75')](util['format'](_0xc58c('0x6f'),_0x3e90c2['params']['id'],_0x5909a5));}else{return _0x92faba[_0xc58c('0x19')](0xcc);}})[_0xc58c('0x46')](handleError(_0x92faba,null));};
\ No newline at end of file