Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / jscriptyProject / jscriptyProject.controller.js
index 9546f53..fc784f2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9d41=['status','end','count','offset','set','json','apply','reject','save','update','then','get','Projects','destroy','error','name','send','index','map','JscriptyProject','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','type','VIRTUAL','filter','includeAll','include','findAll','rows','catch','show','params','merge','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','clone','options','find','omit','createdAt','updatedAt','body','UserProfileSection','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getSessions','findOne','JscriptySessionReport','ProjectId','getAnswers','JscriptyAnswerReport','number','fromCharCode','toString','indexOf','getSummary','startTime','starttime','parse','JscriptyQuestionReport','-createdAt','questionId','question','format','YYYY-MM-DD\x20HH:mm:ss','answer','push','now','/tmp/Jscripty_Project_%d_Summary_%s.csv','setHeader','Jscripty_Project_%d_Summary_%s.csv','Content-type','text/csv','download','sendStatus','html-pdf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','ejs','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb'];(function(_0xf9e113,_0x5ee17d){var _0x45bbf0=function(_0x2c6b32){while(--_0x2c6b32){_0xf9e113['push'](_0xf9e113['shift']());}};_0x45bbf0(++_0x5ee17d);}(_0x9d41,0xd8));var _0x19d4=function(_0x3c04f9,_0x58f9b6){_0x3c04f9=_0x3c04f9-0x0;var _0x46b16f=_0x9d41[_0x3c04f9];return _0x46b16f;};'use strict';var pdf=require(_0x19d4('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x19d4('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x19d4('0x2'));var moment=require(_0x19d4('0x3'));var BPromise=require(_0x19d4('0x4'));var Mustache=require(_0x19d4('0x5'));var util=require('util');var path=require(_0x19d4('0x6'));var sox=require(_0x19d4('0x7'));var csv=require('to-csv');var ejs=require(_0x19d4('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0x19d4('0x9'));var crypto=require(_0x19d4('0xa'));var jsforce=require(_0x19d4('0xb'));var deskjs=require(_0x19d4('0xc'));var toCsv=require(_0x19d4('0xd'));var querystring=require(_0x19d4('0xe'));var Papa=require(_0x19d4('0xf'));var Redis=require(_0x19d4('0x10'));var authService=require(_0x19d4('0x11'));var qs=require(_0x19d4('0x12'));var as=require(_0x19d4('0x13'));var hardwareService=require(_0x19d4('0x14'));var logger=require(_0x19d4('0x15'))(_0x19d4('0x16'));var utils=require(_0x19d4('0x17'));var config=require(_0x19d4('0x18'));var db=require(_0x19d4('0x19'))['db'];function respondWithStatusCode(_0xe815b4,_0x99a091){_0x99a091=_0x99a091||0xcc;return function(_0x1f8b25){if(_0x1f8b25){return _0xe815b4['sendStatus'](_0x99a091);}return _0xe815b4[_0x19d4('0x1a')](_0x99a091)[_0x19d4('0x1b')]();};}function respondWithResult(_0x5a0e27,_0xa80ed){_0xa80ed=_0xa80ed||0xc8;return function(_0x4d31d3){if(_0x4d31d3){return _0x5a0e27['status'](_0xa80ed)['json'](_0x4d31d3);}};}function respondWithFilteredResult(_0x4f58da,_0x5b5cb4){return function(_0x4ad7fc){if(_0x4ad7fc){var _0x226624=_0x4ad7fc[_0x19d4('0x1c')],_0x195b2c=_0x5b5cb4[_0x19d4('0x1d')],_0x5a14ca=_0x5b5cb4['offset']+_0x5b5cb4['limit'],_0x1d49d0;if(_0x5a14ca>=_0x226624){_0x5a14ca=_0x226624;_0x1d49d0=0xc8;}else{_0x1d49d0=0xce;}_0x4f58da[_0x19d4('0x1a')](_0x1d49d0);return _0x4f58da[_0x19d4('0x1e')]('Content-Range',_0x195b2c+'-'+_0x5a14ca+'/'+_0x226624)[_0x19d4('0x1f')](_0x4ad7fc);}return null;};}function patchUpdates(_0x227b34){return function(_0x419a46){try{jsonpatch[_0x19d4('0x20')](_0x419a46,_0x227b34,!![]);}catch(_0x47579e){return BPromise[_0x19d4('0x21')](_0x47579e);}return _0x419a46[_0x19d4('0x22')]();};}function saveUpdates(_0x495363,_0x5ebf96){return function(_0x1e066c){if(_0x1e066c){return _0x1e066c[_0x19d4('0x23')](_0x495363)[_0x19d4('0x24')](function(_0x336fef){return _0x336fef;});}return null;};}function removeEntity(_0x16bbd2,_0x36c2d3){return function(_0x598cb9){if(_0x598cb9){return _0x598cb9['destroy']()[_0x19d4('0x24')](function(){var _0x504bfb=_0x598cb9[_0x19d4('0x25')]({'plain':!![]});var _0x20df28=_0x19d4('0x26');return db['UserProfileResource'][_0x19d4('0x27')]({'where':{'type':_0x20df28,'resourceId':_0x504bfb['id']}})['then'](function(){return _0x598cb9;});})[_0x19d4('0x24')](function(){_0x16bbd2[_0x19d4('0x1a')](0xcc)[_0x19d4('0x1b')]();});}};}function handleEntityNotFound(_0x3a40e8,_0x1ce511){return function(_0xa0f902){if(!_0xa0f902){_0x3a40e8['sendStatus'](0x194);}return _0xa0f902;};}function handleError(_0x5e90f9,_0x4bc90e){_0x4bc90e=_0x4bc90e||0x1f4;return function(_0xcc66da){logger[_0x19d4('0x28')](_0xcc66da['stack']);if(_0xcc66da[_0x19d4('0x29')]){delete _0xcc66da[_0x19d4('0x29')];}_0x5e90f9[_0x19d4('0x1a')](_0x4bc90e)[_0x19d4('0x2a')](_0xcc66da);};}exports[_0x19d4('0x2b')]=function(_0xd83423,_0x249516){var _0x3967d0={},_0x24afdf={},_0x40bb98={'count':0x0,'rows':[]};var _0x45fd1e=_[_0x19d4('0x2c')](db[_0x19d4('0x2d')][_0x19d4('0x2e')],function(_0x293ec3){return{'name':_0x293ec3[_0x19d4('0x2f')],'type':_0x293ec3['type'][_0x19d4('0x30')]};});_0x24afdf[_0x19d4('0x31')]=_[_0x19d4('0x2c')](_0x45fd1e,_0x19d4('0x29'));_0x24afdf[_0x19d4('0x32')]=_[_0x19d4('0x33')](_0xd83423[_0x19d4('0x32')]);_0x24afdf[_0x19d4('0x34')]=_[_0x19d4('0x35')](_0x24afdf[_0x19d4('0x31')],_0x24afdf['query']);_0x3967d0[_0x19d4('0x36')]=_[_0x19d4('0x35')](_0x24afdf[_0x19d4('0x31')],qs['fields'](_0xd83423[_0x19d4('0x32')][_0x19d4('0x37')]));_0x3967d0[_0x19d4('0x36')]=_0x3967d0[_0x19d4('0x36')][_0x19d4('0x38')]?_0x3967d0['attributes']:_0x24afdf[_0x19d4('0x31')];if(!_0xd83423[_0x19d4('0x32')][_0x19d4('0x39')](_0x19d4('0x3a'))){_0x3967d0[_0x19d4('0x3b')]=qs[_0x19d4('0x3b')](_0xd83423[_0x19d4('0x32')]['limit']);_0x3967d0[_0x19d4('0x1d')]=qs['offset'](_0xd83423[_0x19d4('0x32')][_0x19d4('0x1d')]);}_0x3967d0[_0x19d4('0x3c')]=qs[_0x19d4('0x3d')](_0xd83423[_0x19d4('0x32')][_0x19d4('0x3d')]);_0x3967d0[_0x19d4('0x3e')]=qs[_0x19d4('0x34')](_[_0x19d4('0x3f')](_0xd83423['query'],_0x24afdf['filters']),_0x45fd1e);if(_0xd83423[_0x19d4('0x32')]['filter']){_0x3967d0[_0x19d4('0x3e')]=_['merge'](_0x3967d0[_0x19d4('0x3e')],{'$or':_[_0x19d4('0x2c')](_0x45fd1e,function(_0x329d67){if(_0x329d67[_0x19d4('0x40')]!==_0x19d4('0x41')){var _0x1ba3ca={};_0x1ba3ca[_0x329d67[_0x19d4('0x29')]]={'$like':'%'+_0xd83423[_0x19d4('0x32')][_0x19d4('0x42')]+'%'};return _0x1ba3ca;}})});}_0x3967d0=_['merge']({},_0x3967d0,_0xd83423['options']);var _0x23f0db={'where':_0x3967d0[_0x19d4('0x3e')]};return db[_0x19d4('0x2d')][_0x19d4('0x1c')](_0x23f0db)[_0x19d4('0x24')](function(_0x1fdc1e){_0x40bb98[_0x19d4('0x1c')]=_0x1fdc1e;if(_0xd83423[_0x19d4('0x32')][_0x19d4('0x43')]){_0x3967d0[_0x19d4('0x44')]=[{'all':!![]}];}return db[_0x19d4('0x2d')][_0x19d4('0x45')](_0x3967d0);})[_0x19d4('0x24')](function(_0x230244){_0x40bb98[_0x19d4('0x46')]=_0x230244;return _0x40bb98;})[_0x19d4('0x24')](respondWithFilteredResult(_0x249516,_0x3967d0))[_0x19d4('0x47')](handleError(_0x249516,null));};exports[_0x19d4('0x48')]=function(_0x32f3aa,_0x17f60f){var _0x4a3cd5={'raw':![],'where':{'id':_0x32f3aa[_0x19d4('0x49')]['id']}},_0x549e13={};_0x549e13[_0x19d4('0x31')]=_['keys'](db[_0x19d4('0x2d')][_0x19d4('0x2e')]);_0x549e13['query']=_['keys'](_0x32f3aa['query']);_0x549e13['filters']=_[_0x19d4('0x35')](_0x549e13[_0x19d4('0x31')],_0x549e13['query']);_0x4a3cd5['attributes']=_[_0x19d4('0x35')](_0x549e13[_0x19d4('0x31')],qs[_0x19d4('0x37')](_0x32f3aa['query'][_0x19d4('0x37')]));_0x4a3cd5[_0x19d4('0x36')]=_0x4a3cd5[_0x19d4('0x36')]['length']?_0x4a3cd5[_0x19d4('0x36')]:_0x549e13['model'];if(_0x32f3aa[_0x19d4('0x32')][_0x19d4('0x43')]){_0x4a3cd5['include']=[{'all':!![]}];}_0x4a3cd5=_[_0x19d4('0x4a')]({},_0x4a3cd5,_0x32f3aa['options']);return db[_0x19d4('0x2d')]['find'](_0x4a3cd5)[_0x19d4('0x24')](handleEntityNotFound(_0x17f60f,null))[_0x19d4('0x24')](respondWithResult(_0x17f60f,null))[_0x19d4('0x47')](handleError(_0x17f60f,null));};exports[_0x19d4('0x4b')]=function(_0x4bce88,_0xa4772d){return db[_0x19d4('0x2d')]['create'](_0x4bce88['body'],{})[_0x19d4('0x24')](function(_0x23afe8){var _0x104c98=_0x4bce88[_0x19d4('0x4c')][_0x19d4('0x25')]({'plain':!![]});if(!_0x104c98)throw new Error(_0x19d4('0x4d'));if(_0x104c98[_0x19d4('0x4e')]===_0x19d4('0x4c')){var _0x3ecf98=_0x23afe8['get']({'plain':!![]});var _0x2ceafd=_0x19d4('0x26');return db['UserProfileSection']['find']({'where':{'name':_0x2ceafd,'userProfileId':_0x104c98[_0x19d4('0x4f')]},'raw':!![]})[_0x19d4('0x24')](function(_0x2a237c){if(_0x2a237c&&_0x2a237c[_0x19d4('0x50')]===0x0){return db['UserProfileResource']['create']({'name':_0x3ecf98[_0x19d4('0x29')],'resourceId':_0x3ecf98['id'],'type':_0x2a237c[_0x19d4('0x29')],'sectionId':_0x2a237c['id']},{})[_0x19d4('0x24')](function(){return _0x23afe8;});}else{return _0x23afe8;}})[_0x19d4('0x47')](function(_0xde2ca4){logger[_0x19d4('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xde2ca4);throw _0xde2ca4;});}return _0x23afe8;})['then'](respondWithResult(_0xa4772d,0xc9))[_0x19d4('0x47')](handleError(_0xa4772d,null));};exports[_0x19d4('0x51')]=function(_0x227482,_0x44ea06){var _0x5f10bf={'where':{'id':_0x227482[_0x19d4('0x49')]['id']}},_0x23f101={};_0x23f101['model']=_[_0x19d4('0x33')](db[_0x19d4('0x2d')][_0x19d4('0x2e')]);_0x5f10bf[_0x19d4('0x36')]=_['intersection'](_0x23f101['model'],qs[_0x19d4('0x37')](_0x227482[_0x19d4('0x32')][_0x19d4('0x37')]));_0x5f10bf[_0x19d4('0x36')]=_0x5f10bf['attributes'][_0x19d4('0x38')]?_0x5f10bf[_0x19d4('0x36')]:_0x23f101['model'];if(_0x227482[_0x19d4('0x32')][_0x19d4('0x43')]){_0x5f10bf[_0x19d4('0x44')]=[{'all':!![]}];}_0x5f10bf=_[_0x19d4('0x4a')]({},_0x5f10bf,_0x227482[_0x19d4('0x52')]);return db['JscriptyProject'][_0x19d4('0x53')](_0x5f10bf)[_0x19d4('0x24')](handleEntityNotFound(_0x44ea06,null))[_0x19d4('0x24')](function(_0x4c7b98){if(_0x4c7b98){var _0x5302c0=_0x4c7b98[_0x19d4('0x25')]({'plain':!![]});_0x5302c0=qs[_0x19d4('0x54')](_0x5302c0,['id',_0x19d4('0x55'),'updatedAt']);_0x227482['body']=_[_0x19d4('0x54')](_0x227482['body'],['id',_0x19d4('0x55'),_0x19d4('0x56')]);return db[_0x19d4('0x2d')][_0x19d4('0x4b')](_[_0x19d4('0x4a')](_0x5302c0,_0x227482[_0x19d4('0x57')]),{'include':_0x227482[_0x19d4('0x32')][_0x19d4('0x43')]?[{'all':!![]}]:undefined})[_0x19d4('0x24')](function(_0x22d08c){var _0x26726f=_0x227482[_0x19d4('0x4c')][_0x19d4('0x25')]({'plain':!![]});if(!_0x26726f)throw new Error(_0x19d4('0x4d'));if(_0x26726f['role']==='user'){var _0x40ab04=_0x22d08c[_0x19d4('0x25')]({'plain':!![]});var _0x15467e=_0x19d4('0x26');return db[_0x19d4('0x58')][_0x19d4('0x53')]({'where':{'name':_0x15467e,'userProfileId':_0x26726f[_0x19d4('0x4f')]},'raw':!![]})[_0x19d4('0x24')](function(_0x4a12a1){if(_0x4a12a1&&_0x4a12a1['autoAssociation']===0x0){return db[_0x19d4('0x59')]['create']({'name':_0x40ab04[_0x19d4('0x29')],'resourceId':_0x40ab04['id'],'type':_0x4a12a1[_0x19d4('0x29')],'sectionId':_0x4a12a1['id']},{})['then'](function(){return _0x22d08c;});}else{return _0x22d08c;}})[_0x19d4('0x47')](function(_0x3430d9){logger['error'](_0x19d4('0x5a'),_0x3430d9);throw _0x3430d9;});}return _0x22d08c;});}})[_0x19d4('0x24')](respondWithResult(_0x44ea06,0xc9))['catch'](handleError(_0x44ea06,null));};exports[_0x19d4('0x23')]=function(_0x2231db,_0x612b40){if(_0x2231db[_0x19d4('0x57')]['id']){delete _0x2231db[_0x19d4('0x57')]['id'];}return db[_0x19d4('0x2d')]['find']({'where':{'id':_0x2231db[_0x19d4('0x49')]['id']}})['then'](handleEntityNotFound(_0x612b40,null))[_0x19d4('0x24')](saveUpdates(_0x2231db[_0x19d4('0x57')],null))[_0x19d4('0x24')](respondWithResult(_0x612b40,null))[_0x19d4('0x47')](handleError(_0x612b40,null));};exports[_0x19d4('0x27')]=function(_0x302b23,_0x55a164){return db['JscriptyProject'][_0x19d4('0x53')]({'where':{'id':_0x302b23[_0x19d4('0x49')]['id']}})[_0x19d4('0x24')](handleEntityNotFound(_0x55a164,null))['then'](removeEntity(_0x55a164,null))['catch'](handleError(_0x55a164,null));};exports[_0x19d4('0x5b')]=function(_0x1ce941,_0xb47ab4,_0x57b032){var _0x5f2d0e={'raw':!![],'where':{}};var _0x357051={};var _0x215dac={'count':0x0,'rows':[]};return db['JscriptyProject'][_0x19d4('0x5c')]({'where':{'id':_0x1ce941[_0x19d4('0x49')]['id']}})[_0x19d4('0x24')](handleEntityNotFound(_0xb47ab4,null))['then'](function(_0xf707e8){if(_0xf707e8){_0x357051[_0x19d4('0x31')]=_[_0x19d4('0x33')](db[_0x19d4('0x5d')][_0x19d4('0x2e')]);_0x357051['query']=_[_0x19d4('0x33')](_0x1ce941[_0x19d4('0x32')]);_0x357051[_0x19d4('0x34')]=_['intersection'](_0x357051[_0x19d4('0x31')],_0x357051[_0x19d4('0x32')]);_0x5f2d0e[_0x19d4('0x36')]=_[_0x19d4('0x35')](_0x357051[_0x19d4('0x31')],qs[_0x19d4('0x37')](_0x1ce941[_0x19d4('0x32')][_0x19d4('0x37')]));_0x5f2d0e[_0x19d4('0x36')]=_0x5f2d0e[_0x19d4('0x36')][_0x19d4('0x38')]?_0x5f2d0e[_0x19d4('0x36')]:_0x357051[_0x19d4('0x31')];if(!_0x1ce941[_0x19d4('0x32')]['hasOwnProperty'](_0x19d4('0x3a'))){_0x5f2d0e['limit']=qs[_0x19d4('0x3b')](_0x1ce941['query'][_0x19d4('0x3b')]);_0x5f2d0e['offset']=qs[_0x19d4('0x1d')](_0x1ce941['query'][_0x19d4('0x1d')]);}_0x5f2d0e['order']=qs[_0x19d4('0x3d')](_0x1ce941[_0x19d4('0x32')][_0x19d4('0x3d')]);_0x5f2d0e[_0x19d4('0x3e')]=qs[_0x19d4('0x34')](_[_0x19d4('0x3f')](_0x1ce941[_0x19d4('0x32')],_0x357051[_0x19d4('0x34')]));_0x5f2d0e[_0x19d4('0x3e')][_0x19d4('0x5e')]=_0xf707e8['id'];if(_0x1ce941[_0x19d4('0x32')][_0x19d4('0x42')]){_0x5f2d0e[_0x19d4('0x3e')]=_[_0x19d4('0x4a')](_0x5f2d0e[_0x19d4('0x3e')],{'$or':_[_0x19d4('0x2c')](_0x5f2d0e[_0x19d4('0x36')],function(_0x4624a1){var _0x354690={};_0x354690[_0x4624a1]={'$like':'%'+_0x1ce941[_0x19d4('0x32')]['filter']+'%'};return _0x354690;})});}_0x5f2d0e=_[_0x19d4('0x4a')]({},_0x5f2d0e,_0x1ce941[_0x19d4('0x52')]);return db['JscriptySessionReport'][_0x19d4('0x1c')]({'where':_0x5f2d0e[_0x19d4('0x3e')]})['then'](function(_0x3cc64e){_0x215dac[_0x19d4('0x1c')]=_0x3cc64e;if(_0x1ce941['query'][_0x19d4('0x43')]){_0x5f2d0e[_0x19d4('0x44')]=[{'all':!![]}];}return db[_0x19d4('0x5d')]['findAll'](_0x5f2d0e);})[_0x19d4('0x24')](function(_0x599fde){_0x215dac[_0x19d4('0x46')]=_0x599fde;return _0x215dac;});}})['then'](respondWithFilteredResult(_0xb47ab4,_0x5f2d0e))[_0x19d4('0x47')](handleError(_0xb47ab4,null));};exports[_0x19d4('0x5f')]=function(_0x49bbfd,_0x30f99b,_0x31783e){var _0x3c5102={'raw':!![],'where':{}};var _0x35cec8={};var _0x434241={'count':0x0,'rows':[]};return db['JscriptyProject'][_0x19d4('0x5c')]({'where':{'id':_0x49bbfd[_0x19d4('0x49')]['id']}})[_0x19d4('0x24')](handleEntityNotFound(_0x30f99b,null))[_0x19d4('0x24')](function(_0x33db9b){if(_0x33db9b){_0x35cec8[_0x19d4('0x31')]=_[_0x19d4('0x33')](db[_0x19d4('0x60')]['rawAttributes']);_0x35cec8[_0x19d4('0x32')]=_['keys'](_0x49bbfd[_0x19d4('0x32')]);_0x35cec8[_0x19d4('0x34')]=_[_0x19d4('0x35')](_0x35cec8[_0x19d4('0x31')],_0x35cec8[_0x19d4('0x32')]);_0x3c5102[_0x19d4('0x36')]=_[_0x19d4('0x35')](_0x35cec8['model'],qs[_0x19d4('0x37')](_0x49bbfd['query'][_0x19d4('0x37')]));_0x3c5102[_0x19d4('0x36')]=_0x3c5102[_0x19d4('0x36')][_0x19d4('0x38')]?_0x3c5102[_0x19d4('0x36')]:_0x35cec8['model'];if(!_0x49bbfd[_0x19d4('0x32')]['hasOwnProperty'](_0x19d4('0x3a'))){_0x3c5102[_0x19d4('0x3b')]=qs[_0x19d4('0x3b')](_0x49bbfd[_0x19d4('0x32')][_0x19d4('0x3b')]);_0x3c5102[_0x19d4('0x1d')]=qs[_0x19d4('0x1d')](_0x49bbfd[_0x19d4('0x32')][_0x19d4('0x1d')]);}_0x3c5102[_0x19d4('0x3c')]=qs[_0x19d4('0x3d')](_0x49bbfd[_0x19d4('0x32')][_0x19d4('0x3d')]);_0x3c5102[_0x19d4('0x3e')]=qs[_0x19d4('0x34')](_[_0x19d4('0x3f')](_0x49bbfd['query'],_0x35cec8[_0x19d4('0x34')]));_0x3c5102[_0x19d4('0x3e')][_0x19d4('0x5e')]=_0x33db9b['id'];if(_0x49bbfd['query'][_0x19d4('0x42')]){_0x3c5102[_0x19d4('0x3e')]=_[_0x19d4('0x4a')](_0x3c5102['where'],{'$or':_['map'](_0x3c5102[_0x19d4('0x36')],function(_0x54747f){var _0x1043b7={};_0x1043b7[_0x54747f]={'$like':'%'+_0x49bbfd[_0x19d4('0x32')][_0x19d4('0x42')]+'%'};return _0x1043b7;})});}_0x3c5102=_[_0x19d4('0x4a')]({},_0x3c5102,_0x49bbfd[_0x19d4('0x52')]);return db[_0x19d4('0x60')][_0x19d4('0x1c')]({'where':_0x3c5102[_0x19d4('0x3e')]})[_0x19d4('0x24')](function(_0x2aadf4){_0x434241['count']=_0x2aadf4;if(_0x49bbfd[_0x19d4('0x32')]['includeAll']){_0x3c5102[_0x19d4('0x44')]=[{'all':!![]}];}return db[_0x19d4('0x60')]['findAll'](_0x3c5102);})[_0x19d4('0x24')](function(_0x2282cb){_0x434241[_0x19d4('0x46')]=_0x2282cb;return _0x434241;});}})[_0x19d4('0x24')](respondWithFilteredResult(_0x30f99b,_0x3c5102))[_0x19d4('0x47')](handleError(_0x30f99b,null));};function char(_0x40d24a){return _0x19d4('0x61')===typeof _0x40d24a?String[_0x19d4('0x62')][_0x19d4('0x20')](null,arguments):_0x40d24a;}function needsEncapsulation(_0x264fc8){return!!_0x264fc8&&(_0x264fc8[_0x19d4('0x63')]()[_0x19d4('0x64')](char(0xd))>=0x0||_0x264fc8[_0x19d4('0x63')]()[_0x19d4('0x64')](char(0xa))>=0x0||_0x264fc8[_0x19d4('0x63')]()[_0x19d4('0x64')](char(0x2c))>=0x0||_0x264fc8[_0x19d4('0x63')]()['indexOf'](char(0x22))>=0x0);}function encapsulate(_0xf22903){var _0x1ad757=char(0x22),_0x100106='\x5c'+char(0x22),_0x235964=_0xf22903[_0x19d4('0x63')]()['replace'](new RegExp(_0x1ad757,'g'),_0x100106);return _0x1ad757+_0x235964+_0x1ad757;}exports[_0x19d4('0x65')]=function(_0x4451d9,_0x3317f8,_0x2ce29d){var _0x52f397,_0x139334;var _0x4131f2={'where':{'ProjectId':_0x4451d9['params']['id']}};if(_0x4451d9[_0x19d4('0x32')][_0x19d4('0x66')]){_0x4131f2[_0x19d4('0x3e')][_0x19d4('0x67')]=JSON[_0x19d4('0x68')](_0x4451d9[_0x19d4('0x32')][_0x19d4('0x66')]);}return db[_0x19d4('0x5d')][_0x19d4('0x45')](_0x4131f2)[_0x19d4('0x24')](handleEntityNotFound(_0x3317f8,null))[_0x19d4('0x24')](function(_0x33e0b1){if(_0x33e0b1){_0x52f397=_0x33e0b1;return db[_0x19d4('0x69')]['findAll']({'where':{'SessionId':{'$in':_[_0x19d4('0x2c')](_0x52f397,'id')},'ProjectId':_0x4451d9[_0x19d4('0x49')]['id']},'order':_0x19d4('0x6a')});}})[_0x19d4('0x24')](handleEntityNotFound(_0x3317f8,null))['then'](function(_0x5c71cc){if(_0x5c71cc){_0x139334=_0x5c71cc;var _0x43e844={};for(var _0xea5856=0x0,_0x381105=_0x139334['length'];_0xea5856<_0x381105;_0xea5856++){if(!_0x43e844[_0x19d4('0x39')](_0x139334[_0xea5856][_0x19d4('0x6b')])){_0x43e844[_0x139334[_0xea5856][_0x19d4('0x6b')]]=needsEncapsulation(_0x139334[_0xea5856][_0x19d4('0x6c')])?encapsulate(_0x139334[_0xea5856][_0x19d4('0x6c')]):_0x139334[_0xea5856][_0x19d4('0x6c')];}}var _0x1160c9=[],_0x10a7a3={};for(var _0x50cec5=0x0,_0x2e3fc5=_0x52f397[_0x19d4('0x38')];_0x50cec5<_0x2e3fc5;_0x50cec5++){_0x10a7a3={'ProjectId':_0x4451d9['params']['id'],'SessionId':_0x52f397[_0x50cec5]['id'],'StartTime':moment(_0x52f397[_0x50cec5]['starttime'])[_0x19d4('0x6d')](_0x19d4('0x6e'))};for(var _0x138404=0x0,_0x38e2d3=_0x139334['length'];_0x138404<_0x38e2d3;_0x138404++){if(_0x139334[_0x138404]['SessionId']==_0x52f397[_0x50cec5]['id']&&_0x43e844[_0x19d4('0x39')](_0x139334[_0x138404][_0x19d4('0x6b')])){_0x10a7a3[_0x43e844[_0x139334[_0x138404][_0x19d4('0x6b')]]]=_0x139334[_0x138404][_0x19d4('0x6f')];}}for(var _0x488914 in _0x43e844){if(!_0x10a7a3[_0x19d4('0x39')](_0x43e844[_0x488914])){_0x10a7a3[_0x43e844[_0x488914]]=null;}}_0x1160c9[_0x19d4('0x70')](_0x10a7a3);}return _0x1160c9;}})[_0x19d4('0x24')](function(_0x2fec42){if(!_['isEmpty'](_0x2fec42)){var _0x5cfe74=toCsv(_0x2fec42);var _0x1f07ca=Date[_0x19d4('0x71')]();fs['writeFileSync'](util['format'](_0x19d4('0x72'),_0x4451d9[_0x19d4('0x49')]['id'],_0x1f07ca),_0x5cfe74);_0x3317f8[_0x19d4('0x73')]('Content-disposition','attachment;\x20filename='+util[_0x19d4('0x6d')](_0x19d4('0x74'),_0x4451d9[_0x19d4('0x49')]['id'],_0x1f07ca));_0x3317f8[_0x19d4('0x73')](_0x19d4('0x75'),_0x19d4('0x76'));return _0x3317f8[_0x19d4('0x77')](util[_0x19d4('0x6d')](_0x19d4('0x72'),_0x4451d9[_0x19d4('0x49')]['id'],_0x1f07ca));}else{return _0x3317f8[_0x19d4('0x78')](0xcc);}})[_0x19d4('0x47')](handleError(_0x3317f8,null));};
\ No newline at end of file
+var _0x4f3c=['Content-type','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','undefined','limit','offset','count','set','Content-Range','apply','reject','then','destroy','get','Projects','UserProfileResource','error','name','index','JscriptyProject','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','length','order','sort','pick','filter','where','merge','map','VIRTUAL','options','includeAll','findAll','catch','show','params','keys','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','clone','include','omit','createdAt','updatedAt','body','UserProfileSection','autoAssociation','JscriptySessionReport','hasOwnProperty','ProjectId','rows','JscriptyAnswerReport','number','fromCharCode','toString','indexOf','replace','startTime','starttime','parse','JscriptyQuestionReport','questionId','question','format','SessionId','answer','push','isEmpty','now','writeFileSync','/tmp/Jscripty_Project_%d_Summary_%s.csv','Content-disposition','Jscripty_Project_%d_Summary_%s.csv','setHeader'];(function(_0x21195f,_0x54675e){var _0x21b1fe=function(_0x39da99){while(--_0x39da99){_0x21195f['push'](_0x21195f['shift']());}};_0x21b1fe(++_0x54675e);}(_0x4f3c,0x15d));var _0xc4f3=function(_0x59fffa,_0x5a61db){_0x59fffa=_0x59fffa-0x0;var _0x281d4e=_0x4f3c[_0x59fffa];return _0x281d4e;};'use strict';var emlformat=require(_0xc4f3('0x0'));var rimraf=require(_0xc4f3('0x1'));var zipdir=require(_0xc4f3('0x2'));var jsonpatch=require(_0xc4f3('0x3'));var rp=require(_0xc4f3('0x4'));var moment=require(_0xc4f3('0x5'));var BPromise=require(_0xc4f3('0x6'));var Mustache=require(_0xc4f3('0x7'));var util=require(_0xc4f3('0x8'));var path=require(_0xc4f3('0x9'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xc4f3('0xa'));var fs=require('fs');var fs_extra=require(_0xc4f3('0xb'));var _=require(_0xc4f3('0xc'));var squel=require(_0xc4f3('0xd'));var crypto=require(_0xc4f3('0xe'));var jsforce=require(_0xc4f3('0xf'));var deskjs=require(_0xc4f3('0x10'));var toCsv=require(_0xc4f3('0x11'));var querystring=require(_0xc4f3('0x12'));var Papa=require(_0xc4f3('0x13'));var Redis=require('ioredis');var authService=require(_0xc4f3('0x14'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc4f3('0x15'));var logger=require('../../config/logger')(_0xc4f3('0x16'));var utils=require(_0xc4f3('0x17'));var config=require(_0xc4f3('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0xc4f3('0x19'))['db'];function respondWithStatusCode(_0x4e869e,_0x498374){_0x498374=_0x498374||0xcc;return function(_0x4d1c74){if(_0x4d1c74){return _0x4e869e[_0xc4f3('0x1a')](_0x498374);}return _0x4e869e[_0xc4f3('0x1b')](_0x498374)[_0xc4f3('0x1c')]();};}function respondWithResult(_0x3ffd95,_0x53e5c4){_0x53e5c4=_0x53e5c4||0xc8;return function(_0x12981d){if(_0x12981d){return _0x3ffd95[_0xc4f3('0x1b')](_0x53e5c4)[_0xc4f3('0x1d')](_0x12981d);}};}function respondWithFilteredResult(_0x47814f,_0x5583fa){return function(_0x927b26){if(_0x927b26){var _0x3a4ff3=typeof _0x5583fa['offset']===_0xc4f3('0x1e')&&typeof _0x5583fa[_0xc4f3('0x1f')]===_0xc4f3('0x1e');var _0x53b0b6=_0x927b26['count'];var _0xbc5595=_0x3a4ff3?0x0:_0x5583fa[_0xc4f3('0x20')];var _0x1dc5a8=_0x3a4ff3?_0x927b26[_0xc4f3('0x21')]:_0x5583fa['offset']+_0x5583fa[_0xc4f3('0x1f')];var _0x41e2bd;if(_0x1dc5a8>=_0x53b0b6){_0x1dc5a8=_0x53b0b6;_0x41e2bd=0xc8;}else{_0x41e2bd=0xce;}_0x47814f[_0xc4f3('0x1b')](_0x41e2bd);return _0x47814f[_0xc4f3('0x22')](_0xc4f3('0x23'),_0xbc5595+'-'+_0x1dc5a8+'/'+_0x53b0b6)[_0xc4f3('0x1d')](_0x927b26);}return null;};}function patchUpdates(_0x35111f){return function(_0x2bacbc){try{jsonpatch[_0xc4f3('0x24')](_0x2bacbc,_0x35111f,!![]);}catch(_0x16e4e7){return BPromise[_0xc4f3('0x25')](_0x16e4e7);}return _0x2bacbc['save']();};}function saveUpdates(_0x27f7e1,_0xb9b864){return function(_0x4b19a3){if(_0x4b19a3){return _0x4b19a3['update'](_0x27f7e1)[_0xc4f3('0x26')](function(_0x154729){return _0x154729;});}return null;};}function removeEntity(_0x561ea3,_0x5b3ac3){return function(_0x1f04a7){if(_0x1f04a7){return _0x1f04a7[_0xc4f3('0x27')]()[_0xc4f3('0x26')](function(){var _0x5f1d69=_0x1f04a7[_0xc4f3('0x28')]({'plain':!![]});var _0x460ee7=_0xc4f3('0x29');return db[_0xc4f3('0x2a')]['destroy']({'where':{'type':_0x460ee7,'resourceId':_0x5f1d69['id']}})[_0xc4f3('0x26')](function(){return _0x1f04a7;});})[_0xc4f3('0x26')](function(){_0x561ea3[_0xc4f3('0x1b')](0xcc)[_0xc4f3('0x1c')]();});}};}function handleEntityNotFound(_0x67765a,_0x278d0a){return function(_0x2912e4){if(!_0x2912e4){_0x67765a['sendStatus'](0x194);}return _0x2912e4;};}function handleError(_0x45c294,_0x26b1ce){_0x26b1ce=_0x26b1ce||0x1f4;return function(_0x7e4227){logger[_0xc4f3('0x2b')](_0x7e4227['stack']);if(_0x7e4227[_0xc4f3('0x2c')]){delete _0x7e4227[_0xc4f3('0x2c')];}_0x45c294['status'](_0x26b1ce)['send'](_0x7e4227);};}exports[_0xc4f3('0x2d')]=function(_0x2c05c4,_0x5500f3){var _0x3c1722={},_0x1bcb2a={},_0x303b12={'count':0x0,'rows':[]};var _0x393953=_['map'](db[_0xc4f3('0x2e')][_0xc4f3('0x2f')],function(_0x256519){return{'name':_0x256519[_0xc4f3('0x30')],'type':_0x256519[_0xc4f3('0x31')][_0xc4f3('0x32')]};});_0x1bcb2a[_0xc4f3('0x33')]=_['map'](_0x393953,_0xc4f3('0x2c'));_0x1bcb2a[_0xc4f3('0x34')]=_['keys'](_0x2c05c4[_0xc4f3('0x34')]);_0x1bcb2a[_0xc4f3('0x35')]=_[_0xc4f3('0x36')](_0x1bcb2a['model'],_0x1bcb2a['query']);_0x3c1722[_0xc4f3('0x37')]=_[_0xc4f3('0x36')](_0x1bcb2a[_0xc4f3('0x33')],qs[_0xc4f3('0x38')](_0x2c05c4[_0xc4f3('0x34')][_0xc4f3('0x38')]));_0x3c1722[_0xc4f3('0x37')]=_0x3c1722[_0xc4f3('0x37')][_0xc4f3('0x39')]?_0x3c1722[_0xc4f3('0x37')]:_0x1bcb2a[_0xc4f3('0x33')];if(!_0x2c05c4[_0xc4f3('0x34')]['hasOwnProperty']('nolimit')){_0x3c1722[_0xc4f3('0x1f')]=qs[_0xc4f3('0x1f')](_0x2c05c4[_0xc4f3('0x34')][_0xc4f3('0x1f')]);_0x3c1722[_0xc4f3('0x20')]=qs[_0xc4f3('0x20')](_0x2c05c4[_0xc4f3('0x34')][_0xc4f3('0x20')]);}_0x3c1722[_0xc4f3('0x3a')]=qs['sort'](_0x2c05c4[_0xc4f3('0x34')][_0xc4f3('0x3b')]);_0x3c1722['where']=qs['filters'](_[_0xc4f3('0x3c')](_0x2c05c4[_0xc4f3('0x34')],_0x1bcb2a['filters']),_0x393953);if(_0x2c05c4[_0xc4f3('0x34')][_0xc4f3('0x3d')]){_0x3c1722[_0xc4f3('0x3e')]=_[_0xc4f3('0x3f')](_0x3c1722[_0xc4f3('0x3e')],{'$or':_[_0xc4f3('0x40')](_0x393953,function(_0x59d916){if(_0x59d916[_0xc4f3('0x31')]!==_0xc4f3('0x41')){var _0x1e82c0={};_0x1e82c0[_0x59d916[_0xc4f3('0x2c')]]={'$like':'%'+_0x2c05c4[_0xc4f3('0x34')][_0xc4f3('0x3d')]+'%'};return _0x1e82c0;}})});}_0x3c1722=_['merge']({},_0x3c1722,_0x2c05c4[_0xc4f3('0x42')]);var _0x3e4519={'where':_0x3c1722[_0xc4f3('0x3e')]};return db[_0xc4f3('0x2e')][_0xc4f3('0x21')](_0x3e4519)['then'](function(_0x32daa6){_0x303b12[_0xc4f3('0x21')]=_0x32daa6;if(_0x2c05c4['query'][_0xc4f3('0x43')]){_0x3c1722['include']=[{'all':!![]}];}return db['JscriptyProject'][_0xc4f3('0x44')](_0x3c1722);})['then'](function(_0x33ae3b){_0x303b12['rows']=_0x33ae3b;return _0x303b12;})[_0xc4f3('0x26')](respondWithFilteredResult(_0x5500f3,_0x3c1722))[_0xc4f3('0x45')](handleError(_0x5500f3,null));};exports[_0xc4f3('0x46')]=function(_0x30cebc,_0xb04087){var _0x26b04b={'raw':![],'where':{'id':_0x30cebc[_0xc4f3('0x47')]['id']}},_0x325425={};_0x325425[_0xc4f3('0x33')]=_[_0xc4f3('0x48')](db[_0xc4f3('0x2e')]['rawAttributes']);_0x325425[_0xc4f3('0x34')]=_['keys'](_0x30cebc[_0xc4f3('0x34')]);_0x325425[_0xc4f3('0x35')]=_[_0xc4f3('0x36')](_0x325425[_0xc4f3('0x33')],_0x325425[_0xc4f3('0x34')]);_0x26b04b[_0xc4f3('0x37')]=_['intersection'](_0x325425[_0xc4f3('0x33')],qs[_0xc4f3('0x38')](_0x30cebc[_0xc4f3('0x34')][_0xc4f3('0x38')]));_0x26b04b[_0xc4f3('0x37')]=_0x26b04b[_0xc4f3('0x37')][_0xc4f3('0x39')]?_0x26b04b[_0xc4f3('0x37')]:_0x325425[_0xc4f3('0x33')];if(_0x30cebc[_0xc4f3('0x34')][_0xc4f3('0x43')]){_0x26b04b['include']=[{'all':!![]}];}_0x26b04b=_[_0xc4f3('0x3f')]({},_0x26b04b,_0x30cebc[_0xc4f3('0x42')]);return db[_0xc4f3('0x2e')][_0xc4f3('0x49')](_0x26b04b)['then'](handleEntityNotFound(_0xb04087,null))['then'](respondWithResult(_0xb04087,null))[_0xc4f3('0x45')](handleError(_0xb04087,null));};exports[_0xc4f3('0x4a')]=function(_0x374815,_0x539b0a){return db[_0xc4f3('0x2e')][_0xc4f3('0x4a')](_0x374815['body'],{})['then'](function(_0x1fb8d9){var _0x174462=_0x374815[_0xc4f3('0x4b')][_0xc4f3('0x28')]({'plain':!![]});if(!_0x174462)throw new Error(_0xc4f3('0x4c'));if(_0x174462[_0xc4f3('0x4d')]===_0xc4f3('0x4b')){var _0x50eff3=_0x1fb8d9[_0xc4f3('0x28')]({'plain':!![]});var _0x21ab57=_0xc4f3('0x29');return db['UserProfileSection'][_0xc4f3('0x49')]({'where':{'name':_0x21ab57,'userProfileId':_0x174462[_0xc4f3('0x4e')]},'raw':!![]})[_0xc4f3('0x26')](function(_0xf2b8c5){if(_0xf2b8c5&&_0xf2b8c5['autoAssociation']===0x0){return db[_0xc4f3('0x2a')]['create']({'name':_0x50eff3[_0xc4f3('0x2c')],'resourceId':_0x50eff3['id'],'type':_0xf2b8c5['name'],'sectionId':_0xf2b8c5['id']},{})[_0xc4f3('0x26')](function(){return _0x1fb8d9;});}else{return _0x1fb8d9;}})[_0xc4f3('0x45')](function(_0x211333){logger['error'](_0xc4f3('0x4f'),_0x211333);throw _0x211333;});}return _0x1fb8d9;})[_0xc4f3('0x26')](respondWithResult(_0x539b0a,0xc9))['catch'](handleError(_0x539b0a,null));};exports[_0xc4f3('0x50')]=function(_0x117c72,_0x5e299c){var _0x440b26={'where':{'id':_0x117c72[_0xc4f3('0x47')]['id']}},_0x46e658={};_0x46e658[_0xc4f3('0x33')]=_[_0xc4f3('0x48')](db[_0xc4f3('0x2e')][_0xc4f3('0x2f')]);_0x440b26['attributes']=_[_0xc4f3('0x36')](_0x46e658['model'],qs[_0xc4f3('0x38')](_0x117c72['query'][_0xc4f3('0x38')]));_0x440b26['attributes']=_0x440b26[_0xc4f3('0x37')][_0xc4f3('0x39')]?_0x440b26[_0xc4f3('0x37')]:_0x46e658[_0xc4f3('0x33')];if(_0x117c72[_0xc4f3('0x34')][_0xc4f3('0x43')]){_0x440b26[_0xc4f3('0x51')]=[{'all':!![]}];}_0x440b26=_[_0xc4f3('0x3f')]({},_0x440b26,_0x117c72['options']);return db[_0xc4f3('0x2e')][_0xc4f3('0x49')](_0x440b26)['then'](handleEntityNotFound(_0x5e299c,null))[_0xc4f3('0x26')](function(_0x519127){if(_0x519127){var _0x5876d2=_0x519127[_0xc4f3('0x28')]({'plain':!![]});_0x5876d2=qs[_0xc4f3('0x52')](_0x5876d2,['id',_0xc4f3('0x53'),_0xc4f3('0x54')]);_0x117c72[_0xc4f3('0x55')]=_[_0xc4f3('0x52')](_0x117c72[_0xc4f3('0x55')],['id','createdAt',_0xc4f3('0x54')]);return db[_0xc4f3('0x2e')][_0xc4f3('0x4a')](_['merge'](_0x5876d2,_0x117c72[_0xc4f3('0x55')]),{'include':_0x117c72[_0xc4f3('0x34')]['includeAll']?[{'all':!![]}]:undefined})[_0xc4f3('0x26')](function(_0x5ce132){var _0x25ffe5=_0x117c72[_0xc4f3('0x4b')][_0xc4f3('0x28')]({'plain':!![]});if(!_0x25ffe5)throw new Error(_0xc4f3('0x4c'));if(_0x25ffe5[_0xc4f3('0x4d')]===_0xc4f3('0x4b')){var _0x3c5a68=_0x5ce132['get']({'plain':!![]});var _0x56dd7f=_0xc4f3('0x29');return db[_0xc4f3('0x56')][_0xc4f3('0x49')]({'where':{'name':_0x56dd7f,'userProfileId':_0x25ffe5[_0xc4f3('0x4e')]},'raw':!![]})['then'](function(_0x19ec0f){if(_0x19ec0f&&_0x19ec0f[_0xc4f3('0x57')]===0x0){return db[_0xc4f3('0x2a')]['create']({'name':_0x3c5a68[_0xc4f3('0x2c')],'resourceId':_0x3c5a68['id'],'type':_0x19ec0f[_0xc4f3('0x2c')],'sectionId':_0x19ec0f['id']},{})[_0xc4f3('0x26')](function(){return _0x5ce132;});}else{return _0x5ce132;}})['catch'](function(_0xaba55e){logger[_0xc4f3('0x2b')](_0xc4f3('0x4f'),_0xaba55e);throw _0xaba55e;});}return _0x5ce132;});}})[_0xc4f3('0x26')](respondWithResult(_0x5e299c,0xc9))['catch'](handleError(_0x5e299c,null));};exports['update']=function(_0x236359,_0x4b06a4){if(_0x236359['body']['id']){delete _0x236359[_0xc4f3('0x55')]['id'];}return db['JscriptyProject'][_0xc4f3('0x49')]({'where':{'id':_0x236359[_0xc4f3('0x47')]['id']}})[_0xc4f3('0x26')](handleEntityNotFound(_0x4b06a4,null))[_0xc4f3('0x26')](saveUpdates(_0x236359[_0xc4f3('0x55')],null))[_0xc4f3('0x26')](respondWithResult(_0x4b06a4,null))[_0xc4f3('0x45')](handleError(_0x4b06a4,null));};exports['destroy']=function(_0x31ad35,_0x5e88cc){return db['JscriptyProject'][_0xc4f3('0x49')]({'where':{'id':_0x31ad35[_0xc4f3('0x47')]['id']}})[_0xc4f3('0x26')](handleEntityNotFound(_0x5e88cc,null))['then'](removeEntity(_0x5e88cc,null))[_0xc4f3('0x45')](handleError(_0x5e88cc,null));};exports['getSessions']=function(_0x41de89,_0x21dd99,_0x492842){var _0x52679f={'raw':!![],'where':{}};var _0x515e86={};var _0x57e24c={'count':0x0,'rows':[]};return db[_0xc4f3('0x2e')]['findOne']({'where':{'id':_0x41de89['params']['id']}})['then'](handleEntityNotFound(_0x21dd99,null))[_0xc4f3('0x26')](function(_0x1e0832){if(_0x1e0832){_0x515e86['model']=_[_0xc4f3('0x48')](db[_0xc4f3('0x58')][_0xc4f3('0x2f')]);_0x515e86[_0xc4f3('0x34')]=_['keys'](_0x41de89[_0xc4f3('0x34')]);_0x515e86[_0xc4f3('0x35')]=_[_0xc4f3('0x36')](_0x515e86[_0xc4f3('0x33')],_0x515e86[_0xc4f3('0x34')]);_0x52679f[_0xc4f3('0x37')]=_[_0xc4f3('0x36')](_0x515e86[_0xc4f3('0x33')],qs[_0xc4f3('0x38')](_0x41de89[_0xc4f3('0x34')][_0xc4f3('0x38')]));_0x52679f[_0xc4f3('0x37')]=_0x52679f[_0xc4f3('0x37')]['length']?_0x52679f[_0xc4f3('0x37')]:_0x515e86[_0xc4f3('0x33')];if(!_0x41de89[_0xc4f3('0x34')][_0xc4f3('0x59')]('nolimit')){_0x52679f['limit']=qs[_0xc4f3('0x1f')](_0x41de89[_0xc4f3('0x34')]['limit']);_0x52679f['offset']=qs[_0xc4f3('0x20')](_0x41de89['query'][_0xc4f3('0x20')]);}_0x52679f['order']=qs['sort'](_0x41de89['query'][_0xc4f3('0x3b')]);_0x52679f[_0xc4f3('0x3e')]=qs['filters'](_['pick'](_0x41de89[_0xc4f3('0x34')],_0x515e86[_0xc4f3('0x35')]));_0x52679f['where'][_0xc4f3('0x5a')]=_0x1e0832['id'];if(_0x41de89[_0xc4f3('0x34')]['filter']){_0x52679f['where']=_[_0xc4f3('0x3f')](_0x52679f[_0xc4f3('0x3e')],{'$or':_[_0xc4f3('0x40')](_0x52679f[_0xc4f3('0x37')],function(_0x25521c){var _0x3ce7bd={};_0x3ce7bd[_0x25521c]={'$like':'%'+_0x41de89[_0xc4f3('0x34')]['filter']+'%'};return _0x3ce7bd;})});}_0x52679f=_[_0xc4f3('0x3f')]({},_0x52679f,_0x41de89['options']);return db[_0xc4f3('0x58')][_0xc4f3('0x21')]({'where':_0x52679f[_0xc4f3('0x3e')]})['then'](function(_0x18db4b){_0x57e24c[_0xc4f3('0x21')]=_0x18db4b;if(_0x41de89[_0xc4f3('0x34')][_0xc4f3('0x43')]){_0x52679f[_0xc4f3('0x51')]=[{'all':!![]}];}return db[_0xc4f3('0x58')][_0xc4f3('0x44')](_0x52679f);})['then'](function(_0x1cb298){_0x57e24c[_0xc4f3('0x5b')]=_0x1cb298;return _0x57e24c;});}})[_0xc4f3('0x26')](respondWithFilteredResult(_0x21dd99,_0x52679f))[_0xc4f3('0x45')](handleError(_0x21dd99,null));};exports['getAnswers']=function(_0x45b2a7,_0x41be6a,_0x2ab1be){var _0x5845e7={'raw':!![],'where':{}};var _0x45bd37={};var _0x5a54c5={'count':0x0,'rows':[]};return db['JscriptyProject']['findOne']({'where':{'id':_0x45b2a7[_0xc4f3('0x47')]['id']}})[_0xc4f3('0x26')](handleEntityNotFound(_0x41be6a,null))[_0xc4f3('0x26')](function(_0x35dde8){if(_0x35dde8){_0x45bd37['model']=_[_0xc4f3('0x48')](db[_0xc4f3('0x5c')][_0xc4f3('0x2f')]);_0x45bd37[_0xc4f3('0x34')]=_[_0xc4f3('0x48')](_0x45b2a7[_0xc4f3('0x34')]);_0x45bd37[_0xc4f3('0x35')]=_['intersection'](_0x45bd37[_0xc4f3('0x33')],_0x45bd37[_0xc4f3('0x34')]);_0x5845e7['attributes']=_['intersection'](_0x45bd37['model'],qs['fields'](_0x45b2a7[_0xc4f3('0x34')][_0xc4f3('0x38')]));_0x5845e7[_0xc4f3('0x37')]=_0x5845e7[_0xc4f3('0x37')][_0xc4f3('0x39')]?_0x5845e7[_0xc4f3('0x37')]:_0x45bd37['model'];if(!_0x45b2a7[_0xc4f3('0x34')][_0xc4f3('0x59')]('nolimit')){_0x5845e7[_0xc4f3('0x1f')]=qs[_0xc4f3('0x1f')](_0x45b2a7[_0xc4f3('0x34')]['limit']);_0x5845e7[_0xc4f3('0x20')]=qs['offset'](_0x45b2a7['query'][_0xc4f3('0x20')]);}_0x5845e7[_0xc4f3('0x3a')]=qs['sort'](_0x45b2a7[_0xc4f3('0x34')][_0xc4f3('0x3b')]);_0x5845e7[_0xc4f3('0x3e')]=qs[_0xc4f3('0x35')](_[_0xc4f3('0x3c')](_0x45b2a7[_0xc4f3('0x34')],_0x45bd37[_0xc4f3('0x35')]));_0x5845e7['where'][_0xc4f3('0x5a')]=_0x35dde8['id'];if(_0x45b2a7[_0xc4f3('0x34')][_0xc4f3('0x3d')]){_0x5845e7[_0xc4f3('0x3e')]=_[_0xc4f3('0x3f')](_0x5845e7[_0xc4f3('0x3e')],{'$or':_[_0xc4f3('0x40')](_0x5845e7['attributes'],function(_0x10c7b8){var _0x53ac3f={};_0x53ac3f[_0x10c7b8]={'$like':'%'+_0x45b2a7[_0xc4f3('0x34')]['filter']+'%'};return _0x53ac3f;})});}_0x5845e7=_['merge']({},_0x5845e7,_0x45b2a7[_0xc4f3('0x42')]);return db[_0xc4f3('0x5c')][_0xc4f3('0x21')]({'where':_0x5845e7[_0xc4f3('0x3e')]})[_0xc4f3('0x26')](function(_0x59eb46){_0x5a54c5[_0xc4f3('0x21')]=_0x59eb46;if(_0x45b2a7['query']['includeAll']){_0x5845e7[_0xc4f3('0x51')]=[{'all':!![]}];}return db['JscriptyAnswerReport'][_0xc4f3('0x44')](_0x5845e7);})[_0xc4f3('0x26')](function(_0x3529b5){_0x5a54c5[_0xc4f3('0x5b')]=_0x3529b5;return _0x5a54c5;});}})['then'](respondWithFilteredResult(_0x41be6a,_0x5845e7))[_0xc4f3('0x45')](handleError(_0x41be6a,null));};function char(_0x4e95e0){return _0xc4f3('0x5d')===typeof _0x4e95e0?String[_0xc4f3('0x5e')][_0xc4f3('0x24')](null,arguments):_0x4e95e0;}function needsEncapsulation(_0x2a3f4b){return!!_0x2a3f4b&&(_0x2a3f4b[_0xc4f3('0x5f')]()[_0xc4f3('0x60')](char(0xd))>=0x0||_0x2a3f4b[_0xc4f3('0x5f')]()[_0xc4f3('0x60')](char(0xa))>=0x0||_0x2a3f4b['toString']()['indexOf'](char(0x2c))>=0x0||_0x2a3f4b[_0xc4f3('0x5f')]()[_0xc4f3('0x60')](char(0x22))>=0x0);}function encapsulate(_0x2f2718){var _0x207384=char(0x22),_0x308bc7='\x5c'+char(0x22),_0x5aceb7=_0x2f2718[_0xc4f3('0x5f')]()[_0xc4f3('0x61')](new RegExp(_0x207384,'g'),_0x308bc7);return _0x207384+_0x5aceb7+_0x207384;}exports['getSummary']=function(_0x35a91f,_0x54b727,_0x86fe96){var _0x504cb6,_0x2320ae;var _0xb7c143={'where':{'ProjectId':_0x35a91f['params']['id']}};if(_0x35a91f['query'][_0xc4f3('0x62')]){_0xb7c143[_0xc4f3('0x3e')][_0xc4f3('0x63')]=JSON[_0xc4f3('0x64')](_0x35a91f['query'][_0xc4f3('0x62')]);}return db[_0xc4f3('0x58')][_0xc4f3('0x44')](_0xb7c143)[_0xc4f3('0x26')](handleEntityNotFound(_0x54b727,null))[_0xc4f3('0x26')](function(_0x17304e){if(_0x17304e){_0x504cb6=_0x17304e;return db[_0xc4f3('0x65')][_0xc4f3('0x44')]({'where':{'SessionId':{'$in':_[_0xc4f3('0x40')](_0x504cb6,'id')},'ProjectId':_0x35a91f[_0xc4f3('0x47')]['id']},'order':'-createdAt'});}})[_0xc4f3('0x26')](handleEntityNotFound(_0x54b727,null))[_0xc4f3('0x26')](function(_0x229956){if(_0x229956){_0x2320ae=_0x229956;var _0x9a5790={};for(var _0x45d1bf=0x0,_0x58ee59=_0x2320ae['length'];_0x45d1bf<_0x58ee59;_0x45d1bf++){if(!_0x9a5790[_0xc4f3('0x59')](_0x2320ae[_0x45d1bf][_0xc4f3('0x66')])){_0x9a5790[_0x2320ae[_0x45d1bf][_0xc4f3('0x66')]]=needsEncapsulation(_0x2320ae[_0x45d1bf]['question'])?encapsulate(_0x2320ae[_0x45d1bf][_0xc4f3('0x67')]):_0x2320ae[_0x45d1bf][_0xc4f3('0x67')];}}var _0x16b5d2=[],_0x46c85c={};for(var _0x15119e=0x0,_0x345cb8=_0x504cb6[_0xc4f3('0x39')];_0x15119e<_0x345cb8;_0x15119e++){_0x46c85c={'ProjectId':_0x35a91f[_0xc4f3('0x47')]['id'],'SessionId':_0x504cb6[_0x15119e]['id'],'StartTime':moment(_0x504cb6[_0x15119e][_0xc4f3('0x63')])[_0xc4f3('0x68')]('YYYY-MM-DD\x20HH:mm:ss')};for(var _0x21e3a4=0x0,_0x3814b0=_0x2320ae['length'];_0x21e3a4<_0x3814b0;_0x21e3a4++){if(_0x2320ae[_0x21e3a4][_0xc4f3('0x69')]==_0x504cb6[_0x15119e]['id']&&_0x9a5790['hasOwnProperty'](_0x2320ae[_0x21e3a4][_0xc4f3('0x66')])){_0x46c85c[_0x9a5790[_0x2320ae[_0x21e3a4]['questionId']]]=_0x2320ae[_0x21e3a4][_0xc4f3('0x6a')];}}for(var _0x11d42c in _0x9a5790){if(!_0x46c85c[_0xc4f3('0x59')](_0x9a5790[_0x11d42c])){_0x46c85c[_0x9a5790[_0x11d42c]]=null;}}_0x16b5d2[_0xc4f3('0x6b')](_0x46c85c);}return _0x16b5d2;}})[_0xc4f3('0x26')](function(_0x40938a){if(!_[_0xc4f3('0x6c')](_0x40938a)){var _0x5be5c4=toCsv(_0x40938a);var _0xf99527=Date[_0xc4f3('0x6d')]();fs[_0xc4f3('0x6e')](util[_0xc4f3('0x68')](_0xc4f3('0x6f'),_0x35a91f[_0xc4f3('0x47')]['id'],_0xf99527),_0x5be5c4);_0x54b727['setHeader'](_0xc4f3('0x70'),'attachment;\x20filename='+util['format'](_0xc4f3('0x71'),_0x35a91f[_0xc4f3('0x47')]['id'],_0xf99527));_0x54b727[_0xc4f3('0x72')](_0xc4f3('0x73'),'text/csv');return _0x54b727['download'](util['format'](_0xc4f3('0x6f'),_0x35a91f[_0xc4f3('0x47')]['id'],_0xf99527));}else{return _0x54b727[_0xc4f3('0x1a')](0xcc);}})[_0xc4f3('0x45')](handleError(_0x54b727,null));};
\ No newline at end of file