93387e572e39be8992329160b7a758fadec85ec8
[motion-next.git] / server / api / jscriptyProject / jscriptyProject.controller.js
1 const a378_0xded1=['omit','../../mysqldb','UserProfileResource','JscriptyAnswerReport','end','-createdAt','clone','updatedAt','params','name','include','/tmp/Jscripty_Project_%d_Summary_%s.csv','findOne','query','then','util','createdAt','getSessions','length','attributes','json','error','sendStatus','rawAttributes','lodash','undefined','userProfileId','startTime','model','like','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','count','SessionId','set','getSummary','../../components/parsers/qs','order','attachment;\x20filename=','keys','offset','create','parse','options','map','ProjectId','filters','../../config/logger','VIRTUAL','sort','key','catch','number','status','JscriptySessionReport','fields','UserProfileSection','Jscripty_Project_%d_Summary_%s.csv','where','sequelize','answer','Projects','get','YYYY-MM-DD\x20HH:mm:ss','user','Content-disposition','type','autoAssociation','update','fieldName','merge','rows','includeAll','push','show','toString','setHeader','text/csv','fromCharCode','limit','Content-type','role','filter','questionId','nolimit','JscriptyProject','destroy','body','starttime','Unable\x20to\x20retrieve\x20the\x20current\x20user','intersection','indexOf','format','stack','now','apply','getAnswers','pick','question','findAll','JscriptyQuestionReport'];(function(_0xf9876f,_0xded1f8){const _0x2e4fc0=function(_0x1c2069){while(--_0x1c2069){_0xf9876f['push'](_0xf9876f['shift']());}};_0x2e4fc0(++_0xded1f8);}(a378_0xded1,0x177));const a378_0x2e4f=function(_0xf9876f,_0xded1f8){_0xf9876f=_0xf9876f-0x0;let _0x2e4fc0=a378_0xded1[_0xf9876f];return _0x2e4fc0;};const _0x12c80e=a378_0x2e4f;'use strict';const moment=require('moment'),util=require(_0x12c80e('0x28')),fs=require('fs'),_=require(_0x12c80e('0x31')),toCsv=require('to-csv'),qs=require(_0x12c80e('0x3c')),logger=require(_0x12c80e('0x47'))('api'),db=require(_0x12c80e('0x1a'))['db'],{Op}=require(_0x12c80e('0x53'));function respondWithResult(_0x1c2069,_0xa8c044){return _0xa8c044=_0xa8c044||0xc8,function(_0x182c4c){const _0x1fc63a=a378_0x2e4f;if(_0x182c4c)return _0x1c2069[_0x1fc63a('0x4d')](_0xa8c044)[_0x1fc63a('0x2d')](_0x182c4c);};}function respondWithFilteredResult(_0x3bf1f6,_0xaa9e3e){return function(_0x50b2f5){const _0x3b902d=a378_0x2e4f;if(_0x50b2f5){const _0x20195a=_0x50b2f5['count'],_0x2e88e0=_0xaa9e3e['offset'];let _0x388e71=_0xaa9e3e[_0x3b902d('0x40')]+_0xaa9e3e['limit'],_0x3f4ee2;return _0x388e71>=_0x20195a?(_0x388e71=_0x20195a,_0x3f4ee2=0xc8):_0x3f4ee2=0xce,_0x3bf1f6[_0x3b902d('0x4d')](_0x3f4ee2),_0x3bf1f6[_0x3b902d('0x3a')]('Content-Range',_0x2e88e0+'-'+_0x388e71+'/'+_0x20195a)[_0x3b902d('0x2d')](_0x50b2f5);}return null;};}function saveUpdates(_0x14b16b){return function(_0x4782c6){const _0x3bb3d9=a378_0x2e4f;if(_0x4782c6)return _0x4782c6[_0x3bb3d9('0x5c')](_0x14b16b)[_0x3bb3d9('0x27')](function(_0x4d328c){return _0x4d328c;});return null;};}function removeEntity(_0xb31ed){return function(_0x1d3ebb){const _0x48a463=a378_0x2e4f;if(_0x1d3ebb)return _0x1d3ebb[_0x48a463('0xa')]()['then'](function(){const _0x1928b9=_0x48a463,_0x1677cb=_0x1d3ebb[_0x1928b9('0x56')]({'plain':!![]}),_0x596c74=_0x1928b9('0x55');return db['UserProfileResource']['destroy']({'where':{'type':_0x596c74,'resourceId':_0x1677cb['id']}})[_0x1928b9('0x27')](function(){return _0x1d3ebb;});})[_0x48a463('0x27')](function(){const _0x166981=_0x48a463;_0xb31ed[_0x166981('0x4d')](0xcc)[_0x166981('0x1d')]();});};}function handleEntityNotFound(_0x419334){return function(_0x24d8da){const _0x1e1379=a378_0x2e4f;return!_0x24d8da&&_0x419334[_0x1e1379('0x2f')](0x194),_0x24d8da;};}function handleError(_0xc69673,_0x5d2e22){return _0x5d2e22=_0x5d2e22||0x1f4,function(_0x2e6634){const _0x500d3d=a378_0x2e4f;logger['error'](_0x2e6634[_0x500d3d('0x11')]),_0x2e6634[_0x500d3d('0x22')]&&delete _0x2e6634['name'],_0xc69673[_0x500d3d('0x4d')](_0x5d2e22)['send'](_0x2e6634);};}exports['index']=function(_0x2c1651,_0x33cd19){const _0x518b92=_0x12c80e;let _0x66ebe3={};const _0x2845f3={},_0x2d6a29={'count':0x0,'rows':[]},_0xb652e5=_['map'](db[_0x518b92('0x9')][_0x518b92('0x30')],function(_0x289bcf){const _0x3e66eb=_0x518b92;return{'name':_0x289bcf[_0x3e66eb('0x5d')],'type':_0x289bcf[_0x3e66eb('0x5a')][_0x3e66eb('0x4a')]};});_0x2845f3[_0x518b92('0x35')]=_[_0x518b92('0x44')](_0xb652e5,_0x518b92('0x22')),_0x2845f3['query']=_[_0x518b92('0x3f')](_0x2c1651[_0x518b92('0x26')]),_0x2845f3[_0x518b92('0x46')]=_[_0x518b92('0xe')](_0x2845f3[_0x518b92('0x35')],_0x2845f3[_0x518b92('0x26')]),_0x66ebe3[_0x518b92('0x2c')]=_[_0x518b92('0xe')](_0x2845f3['model'],qs[_0x518b92('0x4f')](_0x2c1651[_0x518b92('0x26')][_0x518b92('0x4f')])),_0x66ebe3[_0x518b92('0x2c')]=_0x66ebe3['attributes'][_0x518b92('0x2b')]?_0x66ebe3[_0x518b92('0x2c')]:_0x2845f3[_0x518b92('0x35')];typeof _0x2c1651['query'][_0x518b92('0x8')]==='undefined'&&(_0x66ebe3['limit']=qs[_0x518b92('0x3')](_0x2c1651['query'][_0x518b92('0x3')]),_0x66ebe3[_0x518b92('0x40')]=qs[_0x518b92('0x40')](_0x2c1651[_0x518b92('0x26')][_0x518b92('0x40')]));_0x66ebe3['order']=qs[_0x518b92('0x49')](_0x2c1651[_0x518b92('0x26')][_0x518b92('0x49')]),_0x66ebe3['where']=qs[_0x518b92('0x46')](_[_0x518b92('0x15')](_0x2c1651['query'],_0x2845f3[_0x518b92('0x46')]),_0xb652e5);_0x2c1651[_0x518b92('0x26')][_0x518b92('0x6')]&&(_0x66ebe3[_0x518b92('0x52')]=_[_0x518b92('0x5e')](_0x66ebe3[_0x518b92('0x52')],{[Op['or']]:_[_0x518b92('0x44')](_0xb652e5,function(_0x4cb57d){const _0x3e42ca=_0x518b92;if(_0x4cb57d[_0x3e42ca('0x5a')]!==_0x3e42ca('0x48')){const _0x322da4={};return _0x322da4[_0x4cb57d[_0x3e42ca('0x22')]]={[Op[_0x3e42ca('0x36')]]:'%'+_0x2c1651['query'][_0x3e42ca('0x6')]+'%'},_0x322da4;}})}));_0x66ebe3=_['merge']({},_0x66ebe3,_0x2c1651[_0x518b92('0x43')]);const _0x22879b={'where':_0x66ebe3['where']};return db[_0x518b92('0x9')][_0x518b92('0x38')](_0x22879b)[_0x518b92('0x27')](function(_0x4d5dbe){const _0x27b3b5=_0x518b92;return _0x2d6a29[_0x27b3b5('0x38')]=_0x4d5dbe,_0x2c1651[_0x27b3b5('0x26')][_0x27b3b5('0x60')]&&(_0x66ebe3['include']=[{'all':!![]}]),db['JscriptyProject'][_0x27b3b5('0x17')](_0x66ebe3);})[_0x518b92('0x27')](function(_0x86cae8){const _0x2a3fe6=_0x518b92;return _0x2d6a29[_0x2a3fe6('0x5f')]=_0x86cae8,_0x2d6a29;})[_0x518b92('0x27')](respondWithFilteredResult(_0x33cd19,_0x66ebe3))[_0x518b92('0x4b')](handleError(_0x33cd19,null));},exports[_0x12c80e('0x62')]=function(_0x25e3f4,_0x222201){const _0x462c0d=_0x12c80e;let _0x5afcbd={'raw':![],'where':{'id':_0x25e3f4[_0x462c0d('0x21')]['id']}};const _0x2fe7a1={};return _0x2fe7a1[_0x462c0d('0x35')]=_[_0x462c0d('0x3f')](db['JscriptyProject']['rawAttributes']),_0x2fe7a1['query']=_['keys'](_0x25e3f4[_0x462c0d('0x26')]),_0x2fe7a1['filters']=_[_0x462c0d('0xe')](_0x2fe7a1['model'],_0x2fe7a1['query']),_0x5afcbd[_0x462c0d('0x2c')]=_[_0x462c0d('0xe')](_0x2fe7a1['model'],qs['fields'](_0x25e3f4[_0x462c0d('0x26')][_0x462c0d('0x4f')])),_0x5afcbd[_0x462c0d('0x2c')]=_0x5afcbd[_0x462c0d('0x2c')][_0x462c0d('0x2b')]?_0x5afcbd['attributes']:_0x2fe7a1[_0x462c0d('0x35')],_0x25e3f4['query'][_0x462c0d('0x60')]&&(_0x5afcbd[_0x462c0d('0x23')]=[{'all':!![]}]),_0x5afcbd=_['merge']({},_0x5afcbd,_0x25e3f4[_0x462c0d('0x43')]),db[_0x462c0d('0x9')][_0x462c0d('0x25')](_0x5afcbd)[_0x462c0d('0x27')](handleEntityNotFound(_0x222201,null))['then'](respondWithResult(_0x222201,null))[_0x462c0d('0x4b')](handleError(_0x222201,null));},exports[_0x12c80e('0x41')]=function(_0x507adb,_0x3054cc){const _0x551ead=_0x12c80e;return db[_0x551ead('0x9')][_0x551ead('0x41')](_0x507adb[_0x551ead('0xb')],{})['then'](function(_0x22c8e7){const _0xc93d88=_0x551ead,_0x3c5b48=_0x507adb[_0xc93d88('0x58')][_0xc93d88('0x56')]({'plain':!![]});if(!_0x3c5b48)throw new Error(_0xc93d88('0xd'));if(_0x3c5b48[_0xc93d88('0x5')]===_0xc93d88('0x58')){const _0x5798c1=_0x22c8e7[_0xc93d88('0x56')]({'plain':!![]}),_0x585e18='Projects';return db[_0xc93d88('0x50')]['findOne']({'where':{'name':_0x585e18,'userProfileId':_0x3c5b48[_0xc93d88('0x33')]},'raw':!![]})['then'](function(_0x2bd268){const _0x543dd6=_0xc93d88;return _0x2bd268&&_0x2bd268[_0x543dd6('0x5b')]===0x0?db[_0x543dd6('0x1b')][_0x543dd6('0x41')]({'name':_0x5798c1['name'],'resourceId':_0x5798c1['id'],'type':_0x2bd268[_0x543dd6('0x22')],'sectionId':_0x2bd268['id']},{})[_0x543dd6('0x27')](function(){return _0x22c8e7;}):_0x22c8e7;})[_0xc93d88('0x4b')](function(_0x516ca1){const _0x2f7744=_0xc93d88;logger[_0x2f7744('0x2e')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x516ca1);throw _0x516ca1;});}return _0x22c8e7;})[_0x551ead('0x27')](respondWithResult(_0x3054cc,0xc9))['catch'](handleError(_0x3054cc,null));},exports[_0x12c80e('0x1f')]=function(_0x30bfc9,_0x433469){const _0x3f5d29=_0x12c80e;let _0x114587={'where':{'id':_0x30bfc9[_0x3f5d29('0x21')]['id']}};const _0x58fc0a={};return _0x58fc0a['model']=_[_0x3f5d29('0x3f')](db[_0x3f5d29('0x9')][_0x3f5d29('0x30')]),_0x114587[_0x3f5d29('0x2c')]=_[_0x3f5d29('0xe')](_0x58fc0a[_0x3f5d29('0x35')],qs[_0x3f5d29('0x4f')](_0x30bfc9['query']['fields'])),_0x114587['attributes']=_0x114587[_0x3f5d29('0x2c')][_0x3f5d29('0x2b')]?_0x114587[_0x3f5d29('0x2c')]:_0x58fc0a[_0x3f5d29('0x35')],_0x30bfc9[_0x3f5d29('0x26')]['includeAll']&&(_0x114587[_0x3f5d29('0x23')]=[{'all':!![]}]),_0x114587=_[_0x3f5d29('0x5e')]({},_0x114587,_0x30bfc9[_0x3f5d29('0x43')]),db[_0x3f5d29('0x9')][_0x3f5d29('0x25')](_0x114587)[_0x3f5d29('0x27')](handleEntityNotFound(_0x433469,null))[_0x3f5d29('0x27')](function(_0x36be53){const _0x4ad838=_0x3f5d29;if(_0x36be53){let _0x1acf06=_0x36be53['get']({'plain':!![]});return _0x1acf06=qs[_0x4ad838('0x19')](_0x1acf06,['id',_0x4ad838('0x29'),_0x4ad838('0x20')]),_0x30bfc9[_0x4ad838('0xb')]=_['omit'](_0x30bfc9[_0x4ad838('0xb')],['id','createdAt',_0x4ad838('0x20')]),db['JscriptyProject']['create'](_[_0x4ad838('0x5e')](_0x1acf06,_0x30bfc9[_0x4ad838('0xb')]),{'include':_0x30bfc9['query'][_0x4ad838('0x60')]?[{'all':!![]}]:undefined})['then'](function(_0x568682){const _0x3c4f20=_0x4ad838,_0x2795f4=_0x30bfc9[_0x3c4f20('0x58')][_0x3c4f20('0x56')]({'plain':!![]});if(!_0x2795f4)throw new Error(_0x3c4f20('0xd'));if(_0x2795f4[_0x3c4f20('0x5')]===_0x3c4f20('0x58')){const _0x5126c4=_0x568682[_0x3c4f20('0x56')]({'plain':!![]}),_0x2c5300=_0x3c4f20('0x55');return db[_0x3c4f20('0x50')]['findOne']({'where':{'name':_0x2c5300,'userProfileId':_0x2795f4['userProfileId']},'raw':!![]})['then'](function(_0x45b9a8){const _0x15f535=_0x3c4f20;return _0x45b9a8&&_0x45b9a8[_0x15f535('0x5b')]===0x0?db['UserProfileResource'][_0x15f535('0x41')]({'name':_0x5126c4[_0x15f535('0x22')],'resourceId':_0x5126c4['id'],'type':_0x45b9a8[_0x15f535('0x22')],'sectionId':_0x45b9a8['id']},{})[_0x15f535('0x27')](function(){return _0x568682;}):_0x568682;})[_0x3c4f20('0x4b')](function(_0x17d34a){const _0x275ddc=_0x3c4f20;logger['error'](_0x275ddc('0x37'),_0x17d34a);throw _0x17d34a;});}return _0x568682;});}})[_0x3f5d29('0x27')](respondWithResult(_0x433469,0xc9))[_0x3f5d29('0x4b')](handleError(_0x433469,null));},exports['update']=function(_0x917051,_0x50ebce){const _0x4f9e7c=_0x12c80e;return _0x917051['body']['id']&&delete _0x917051['body']['id'],db[_0x4f9e7c('0x9')][_0x4f9e7c('0x25')]({'where':{'id':_0x917051[_0x4f9e7c('0x21')]['id']}})['then'](handleEntityNotFound(_0x50ebce,null))[_0x4f9e7c('0x27')](saveUpdates(_0x917051[_0x4f9e7c('0xb')],null))[_0x4f9e7c('0x27')](respondWithResult(_0x50ebce,null))[_0x4f9e7c('0x4b')](handleError(_0x50ebce,null));},exports['destroy']=function(_0x5a21be,_0x23fada){const _0x360b8b=_0x12c80e;return db[_0x360b8b('0x9')]['findOne']({'where':{'id':_0x5a21be[_0x360b8b('0x21')]['id']}})[_0x360b8b('0x27')](handleEntityNotFound(_0x23fada,null))[_0x360b8b('0x27')](removeEntity(_0x23fada,null))['catch'](handleError(_0x23fada,null));},exports[_0x12c80e('0x2a')]=function(_0x5cccde,_0xd2a4be){const _0x11cfc2=_0x12c80e;let _0x158581={'raw':!![],'where':{}};const _0x2543b2={},_0x26588b={'count':0x0,'rows':[]};return db['JscriptyProject'][_0x11cfc2('0x25')]({'where':{'id':_0x5cccde[_0x11cfc2('0x21')]['id']}})[_0x11cfc2('0x27')](handleEntityNotFound(_0xd2a4be,null))[_0x11cfc2('0x27')](function(_0x1f89fd){const _0x48bc42=_0x11cfc2;if(_0x1f89fd)return _0x2543b2[_0x48bc42('0x35')]=_[_0x48bc42('0x3f')](db['JscriptySessionReport'][_0x48bc42('0x30')]),_0x2543b2[_0x48bc42('0x26')]=_[_0x48bc42('0x3f')](_0x5cccde[_0x48bc42('0x26')]),_0x2543b2[_0x48bc42('0x46')]=_[_0x48bc42('0xe')](_0x2543b2[_0x48bc42('0x35')],_0x2543b2[_0x48bc42('0x26')]),_0x158581[_0x48bc42('0x2c')]=_[_0x48bc42('0xe')](_0x2543b2['model'],qs[_0x48bc42('0x4f')](_0x5cccde[_0x48bc42('0x26')][_0x48bc42('0x4f')])),_0x158581[_0x48bc42('0x2c')]=_0x158581[_0x48bc42('0x2c')][_0x48bc42('0x2b')]?_0x158581[_0x48bc42('0x2c')]:_0x2543b2[_0x48bc42('0x35')],typeof _0x5cccde[_0x48bc42('0x26')][_0x48bc42('0x8')]===_0x48bc42('0x32')&&(_0x158581[_0x48bc42('0x3')]=qs[_0x48bc42('0x3')](_0x5cccde[_0x48bc42('0x26')]['limit']),_0x158581[_0x48bc42('0x40')]=qs[_0x48bc42('0x40')](_0x5cccde[_0x48bc42('0x26')][_0x48bc42('0x40')])),_0x158581[_0x48bc42('0x3d')]=qs[_0x48bc42('0x49')](_0x5cccde['query'][_0x48bc42('0x49')]),_0x158581[_0x48bc42('0x52')]=qs[_0x48bc42('0x46')](_[_0x48bc42('0x15')](_0x5cccde[_0x48bc42('0x26')],_0x2543b2[_0x48bc42('0x46')])),_0x158581[_0x48bc42('0x52')]['ProjectId']=_0x1f89fd['id'],_0x5cccde['query'][_0x48bc42('0x6')]&&(_0x158581[_0x48bc42('0x52')]=_[_0x48bc42('0x5e')](_0x158581[_0x48bc42('0x52')],{[Op['or']]:_[_0x48bc42('0x44')](_0x158581[_0x48bc42('0x2c')],function(_0x5566c9){const _0x293fac=_0x48bc42,_0x3ed371={};return _0x3ed371[_0x5566c9]={[Op[_0x293fac('0x36')]]:'%'+_0x5cccde[_0x293fac('0x26')]['filter']+'%'},_0x3ed371;})})),_0x158581=_[_0x48bc42('0x5e')]({},_0x158581,_0x5cccde[_0x48bc42('0x43')]),db['JscriptySessionReport']['count']({'where':_0x158581[_0x48bc42('0x52')]})[_0x48bc42('0x27')](function(_0xf8c16a){const _0x538c48=_0x48bc42;return _0x26588b[_0x538c48('0x38')]=_0xf8c16a,_0x5cccde['query']['includeAll']&&(_0x158581[_0x538c48('0x23')]=[{'all':!![]}]),db[_0x538c48('0x4e')]['findAll'](_0x158581);})[_0x48bc42('0x27')](function(_0x144dba){return _0x26588b['rows']=_0x144dba,_0x26588b;});})['then'](respondWithFilteredResult(_0xd2a4be,_0x158581))['catch'](handleError(_0xd2a4be,null));},exports[_0x12c80e('0x14')]=function(_0x771918,_0x2de4b7){const _0x26602c=_0x12c80e;let _0x4aa8a4={'raw':!![],'where':{}};const _0x4411a3={},_0x217db3={'count':0x0,'rows':[]};return db['JscriptyProject'][_0x26602c('0x25')]({'where':{'id':_0x771918['params']['id']}})['then'](handleEntityNotFound(_0x2de4b7,null))['then'](function(_0x35da43){const _0x33a418=_0x26602c;if(_0x35da43)return _0x4411a3[_0x33a418('0x35')]=_[_0x33a418('0x3f')](db[_0x33a418('0x1c')][_0x33a418('0x30')]),_0x4411a3[_0x33a418('0x26')]=_[_0x33a418('0x3f')](_0x771918[_0x33a418('0x26')]),_0x4411a3[_0x33a418('0x46')]=_[_0x33a418('0xe')](_0x4411a3[_0x33a418('0x35')],_0x4411a3[_0x33a418('0x26')]),_0x4aa8a4['attributes']=_[_0x33a418('0xe')](_0x4411a3[_0x33a418('0x35')],qs['fields'](_0x771918[_0x33a418('0x26')]['fields'])),_0x4aa8a4[_0x33a418('0x2c')]=_0x4aa8a4[_0x33a418('0x2c')][_0x33a418('0x2b')]?_0x4aa8a4[_0x33a418('0x2c')]:_0x4411a3[_0x33a418('0x35')],typeof _0x771918['query'][_0x33a418('0x8')]===_0x33a418('0x32')&&(_0x4aa8a4['limit']=qs['limit'](_0x771918[_0x33a418('0x26')]['limit']),_0x4aa8a4[_0x33a418('0x40')]=qs['offset'](_0x771918['query'][_0x33a418('0x40')])),_0x4aa8a4[_0x33a418('0x3d')]=qs['sort'](_0x771918['query'][_0x33a418('0x49')]),_0x4aa8a4['where']=qs[_0x33a418('0x46')](_['pick'](_0x771918[_0x33a418('0x26')],_0x4411a3[_0x33a418('0x46')])),_0x4aa8a4[_0x33a418('0x52')][_0x33a418('0x45')]=_0x35da43['id'],_0x771918[_0x33a418('0x26')][_0x33a418('0x6')]&&(_0x4aa8a4[_0x33a418('0x52')]=_[_0x33a418('0x5e')](_0x4aa8a4[_0x33a418('0x52')],{[Op['or']]:_[_0x33a418('0x44')](_0x4aa8a4[_0x33a418('0x2c')],function(_0x115457){const _0x1e3cdc=_0x33a418,_0x4ec39b={};return _0x4ec39b[_0x115457]={[Op[_0x1e3cdc('0x36')]]:'%'+_0x771918['query']['filter']+'%'},_0x4ec39b;})})),_0x4aa8a4=_[_0x33a418('0x5e')]({},_0x4aa8a4,_0x771918['options']),db[_0x33a418('0x1c')]['count']({'where':_0x4aa8a4['where']})[_0x33a418('0x27')](function(_0xe12b3){const _0x1d2017=_0x33a418;return _0x217db3['count']=_0xe12b3,_0x771918[_0x1d2017('0x26')][_0x1d2017('0x60')]&&(_0x4aa8a4[_0x1d2017('0x23')]=[{'all':!![]}]),db[_0x1d2017('0x1c')][_0x1d2017('0x17')](_0x4aa8a4);})[_0x33a418('0x27')](function(_0x5e0a1c){return _0x217db3['rows']=_0x5e0a1c,_0x217db3;});})[_0x26602c('0x27')](respondWithFilteredResult(_0x2de4b7,_0x4aa8a4))[_0x26602c('0x4b')](handleError(_0x2de4b7,null));};function char(_0x4cbffd){const _0x3ea099=_0x12c80e;return _0x3ea099('0x4c')===typeof _0x4cbffd?String[_0x3ea099('0x2')][_0x3ea099('0x13')](null,arguments):_0x4cbffd;}function needsEncapsulation(_0x293208){const _0x26c571=_0x12c80e;return!!_0x293208&&(_0x293208['toString']()['indexOf'](char(0xd))>=0x0||_0x293208[_0x26c571('0x63')]()[_0x26c571('0xf')](char(0xa))>=0x0||_0x293208['toString']()[_0x26c571('0xf')](char(0x2c))>=0x0||_0x293208[_0x26c571('0x63')]()[_0x26c571('0xf')](char(0x22))>=0x0);}function encapsulate(_0x88956c){const _0x19f69f=char(0x22),_0xaf61d='\x5c'+char(0x22),_0x4ec53b=_0x88956c['toString']()['replace'](new RegExp(_0x19f69f,'g'),_0xaf61d);return _0x19f69f+_0x4ec53b+_0x19f69f;}exports[_0x12c80e('0x3b')]=function(_0x49b97e,_0x25c54a){const _0x2690c0=_0x12c80e;let _0x4234db,_0x56c7c6;const _0x4becdc={'where':{'ProjectId':_0x49b97e[_0x2690c0('0x21')]['id']}};return _0x49b97e[_0x2690c0('0x26')][_0x2690c0('0x34')]&&(_0x4becdc[_0x2690c0('0x52')]['starttime']=JSON[_0x2690c0('0x42')](_0x49b97e[_0x2690c0('0x26')][_0x2690c0('0x34')])),db['JscriptySessionReport'][_0x2690c0('0x17')](_0x4becdc)[_0x2690c0('0x27')](handleEntityNotFound(_0x25c54a,null))[_0x2690c0('0x27')](function(_0x5cd724){const _0x1fc7af=_0x2690c0;if(_0x5cd724)return _0x4234db=_0x5cd724,db[_0x1fc7af('0x18')][_0x1fc7af('0x17')]({'where':{'SessionId':{[Op['in']]:_['map'](_0x4234db,'id')},'ProjectId':_0x49b97e[_0x1fc7af('0x21')]['id']},'order':_0x1fc7af('0x1e')});})[_0x2690c0('0x27')](handleEntityNotFound(_0x25c54a,null))[_0x2690c0('0x27')](function(_0x4d1ce1){const _0x593da1=_0x2690c0;if(_0x4d1ce1){_0x56c7c6=_0x4d1ce1;const _0xadcd3a={};for(let _0x26abfa=0x0,_0x37d044=_0x56c7c6['length'];_0x26abfa<_0x37d044;_0x26abfa++){typeof _0xadcd3a[_0x56c7c6[_0x26abfa][_0x593da1('0x7')]]===_0x593da1('0x32')&&(_0xadcd3a[_0x56c7c6[_0x26abfa][_0x593da1('0x7')]]=needsEncapsulation(_0x56c7c6[_0x26abfa][_0x593da1('0x16')])?encapsulate(_0x56c7c6[_0x26abfa][_0x593da1('0x16')]):_0x56c7c6[_0x26abfa][_0x593da1('0x16')]);}const _0x1368d9=[];let _0x3cd2f9={};for(let _0x10a2e5=0x0,_0x5b28ec=_0x4234db[_0x593da1('0x2b')];_0x10a2e5<_0x5b28ec;_0x10a2e5++){_0x3cd2f9={'ProjectId':_0x49b97e[_0x593da1('0x21')]['id'],'SessionId':_0x4234db[_0x10a2e5]['id'],'StartTime':moment(_0x4234db[_0x10a2e5][_0x593da1('0xc')])[_0x593da1('0x10')](_0x593da1('0x57'))};for(let _0x216539=0x0,_0x39ad79=_0x56c7c6[_0x593da1('0x2b')];_0x216539<_0x39ad79;_0x216539++){_0x56c7c6[_0x216539][_0x593da1('0x39')]===_0x4234db[_0x10a2e5]['id']&&typeof _0xadcd3a[_0x56c7c6[_0x216539]['questionId']]!=='undefined'&&(_0x3cd2f9[_0xadcd3a[_0x56c7c6[_0x216539][_0x593da1('0x7')]]]=_0x56c7c6[_0x216539][_0x593da1('0x54')]);}for(const _0x151bf3 in _0xadcd3a){typeof _0x3cd2f9[_0xadcd3a[_0x151bf3]]===_0x593da1('0x32')&&(_0x3cd2f9[_0xadcd3a[_0x151bf3]]=null);}_0x1368d9[_0x593da1('0x61')](_0x3cd2f9);}return _0x1368d9;}})[_0x2690c0('0x27')](function(_0x3c9f99){const _0x4adfd3=_0x2690c0;if(!_['isEmpty'](_0x3c9f99)){const _0x598a9f=toCsv(_0x3c9f99),_0x2e0afa=Date[_0x4adfd3('0x12')]();return fs['writeFileSync'](util[_0x4adfd3('0x10')](_0x4adfd3('0x24'),_0x49b97e[_0x4adfd3('0x21')]['id'],_0x2e0afa),_0x598a9f),_0x25c54a[_0x4adfd3('0x0')](_0x4adfd3('0x59'),_0x4adfd3('0x3e')+util['format'](_0x4adfd3('0x51'),_0x49b97e[_0x4adfd3('0x21')]['id'],_0x2e0afa)),_0x25c54a['setHeader'](_0x4adfd3('0x4'),_0x4adfd3('0x1')),_0x25c54a['download'](util[_0x4adfd3('0x10')](_0x4adfd3('0x24'),_0x49b97e[_0x4adfd3('0x21')]['id'],_0x2e0afa));}else return _0x25c54a[_0x4adfd3('0x2f')](0xcc);})[_0x2690c0('0x4b')](handleError(_0x25c54a,null));};