Built motion from commit b51cdcb3f2cb46634587ce1d55ea1b8f32dacea6. Version 3.0.0...
[motion-next.git] / server / api / jscriptyAnswerReport / jscriptyAnswerReport.controller.js
1 const a374_0x4851=['fieldName','api','../../components/parsers/qs','findOne','../../config/logger','lodash','includeAll','attributes','key','sequelize','create','filter','pick','query','name','json','type','length','undefined','JscriptyAnswerReport','rows','count','body','model','sendStatus','then','params','merge','update','send','stack','limit','offset','like','rawAttributes','describe','include','options','keys','where','catch','VIRTUAL','destroy','error','filters','show','findAll','fields','Content-Range','sort','order','intersection','status','end','map'];(function(_0x140783,_0x4851b8){const _0x216776=function(_0x5f1c56){while(--_0x5f1c56){_0x140783['push'](_0x140783['shift']());}};_0x216776(++_0x4851b8);}(a374_0x4851,0x9f));const a374_0x2167=function(_0x140783,_0x4851b8){_0x140783=_0x140783-0x0;let _0x216776=a374_0x4851[_0x140783];return _0x216776;};const _0x3f0a54=a374_0x2167;'use strict';const _=require(_0x3f0a54('0xb')),qs=require(_0x3f0a54('0x8')),logger=require(_0x3f0a54('0xa'))(_0x3f0a54('0x7')),db=require('../../mysqldb')['db'],{Op}=require(_0x3f0a54('0xf'));function respondWithResult(_0x5f1c56,_0x1fabbc){return _0x1fabbc=_0x1fabbc||0xc8,function(_0x1241da){const _0x1a730d=a374_0x2167;if(_0x1241da)return _0x5f1c56[_0x1a730d('0x3')](_0x1fabbc)[_0x1a730d('0x15')](_0x1241da);};}function respondWithFilteredResult(_0x4fdc99,_0x460fc3){return function(_0x272545){const _0x35a661=a374_0x2167;if(_0x272545){const _0x2a036c=_0x272545[_0x35a661('0x1b')],_0x24bce8=_0x460fc3[_0x35a661('0x26')];let _0x1d1148=_0x460fc3['offset']+_0x460fc3[_0x35a661('0x25')],_0x123c27;return _0x1d1148>=_0x2a036c?(_0x1d1148=_0x2a036c,_0x123c27=0xc8):_0x123c27=0xce,_0x4fdc99[_0x35a661('0x3')](_0x123c27),_0x4fdc99['set'](_0x35a661('0x36'),_0x24bce8+'-'+_0x1d1148+'/'+_0x2a036c)[_0x35a661('0x15')](_0x272545);}return null;};}function saveUpdates(_0xd386c4){return function(_0x23895a){const _0x4c9aa6=a374_0x2167;if(_0x23895a)return _0x23895a[_0x4c9aa6('0x22')](_0xd386c4)[_0x4c9aa6('0x1f')](function(_0xdf06b){return _0xdf06b;});return null;};}function removeEntity(_0x49d48d){return function(_0x3aa92c){if(_0x3aa92c)return _0x3aa92c['destroy']()['then'](function(){const _0xff1e64=a374_0x2167;_0x49d48d[_0xff1e64('0x3')](0xcc)[_0xff1e64('0x4')]();});};}function handleEntityNotFound(_0x34de77){return function(_0x3e3a5c){const _0x3a909c=a374_0x2167;return!_0x3e3a5c&&_0x34de77[_0x3a909c('0x1e')](0x194),_0x3e3a5c;};}function handleError(_0x446c05,_0x580b2c){return _0x580b2c=_0x580b2c||0x1f4,function(_0x260248){const _0x58401d=a374_0x2167;logger[_0x58401d('0x31')](_0x260248[_0x58401d('0x24')]),_0x260248[_0x58401d('0x14')]&&delete _0x260248[_0x58401d('0x14')],_0x446c05[_0x58401d('0x3')](_0x580b2c)[_0x58401d('0x23')](_0x260248);};}exports['index']=function(_0x399a2e,_0x23f1b1){const _0x3f94cb=_0x3f0a54;let _0x243b28={};const _0x52d709={},_0x40e16b={'count':0x0,'rows':[]},_0x543da2=_[_0x3f94cb('0x5')](db[_0x3f94cb('0x19')][_0x3f94cb('0x28')],function(_0x2d06c3){const _0x2373e0=_0x3f94cb;return{'name':_0x2d06c3[_0x2373e0('0x6')],'type':_0x2d06c3[_0x2373e0('0x16')][_0x2373e0('0xe')]};});_0x52d709[_0x3f94cb('0x1d')]=_[_0x3f94cb('0x5')](_0x543da2,'name'),_0x52d709[_0x3f94cb('0x13')]=_[_0x3f94cb('0x2c')](_0x399a2e['query']),_0x52d709['filters']=_[_0x3f94cb('0x2')](_0x52d709['model'],_0x52d709['query']),_0x243b28['attributes']=_[_0x3f94cb('0x2')](_0x52d709[_0x3f94cb('0x1d')],qs[_0x3f94cb('0x35')](_0x399a2e[_0x3f94cb('0x13')][_0x3f94cb('0x35')])),_0x243b28[_0x3f94cb('0xd')]=_0x243b28[_0x3f94cb('0xd')][_0x3f94cb('0x17')]?_0x243b28[_0x3f94cb('0xd')]:_0x52d709[_0x3f94cb('0x1d')];typeof _0x399a2e[_0x3f94cb('0x13')]['nolimit']===_0x3f94cb('0x18')&&(_0x243b28['limit']=qs[_0x3f94cb('0x25')](_0x399a2e[_0x3f94cb('0x13')][_0x3f94cb('0x25')]),_0x243b28['offset']=qs['offset'](_0x399a2e[_0x3f94cb('0x13')][_0x3f94cb('0x26')]));_0x243b28[_0x3f94cb('0x1')]=qs[_0x3f94cb('0x0')](_0x399a2e[_0x3f94cb('0x13')][_0x3f94cb('0x0')]),_0x243b28[_0x3f94cb('0x2d')]=qs['filters'](_[_0x3f94cb('0x12')](_0x399a2e[_0x3f94cb('0x13')],_0x52d709[_0x3f94cb('0x32')]),_0x543da2);_0x399a2e[_0x3f94cb('0x13')][_0x3f94cb('0x11')]&&(_0x243b28['where']=_[_0x3f94cb('0x21')](_0x243b28[_0x3f94cb('0x2d')],{[Op['or']]:_[_0x3f94cb('0x5')](_0x543da2,function(_0x5afcd1){const _0x2d4946=_0x3f94cb;if(_0x5afcd1['type']!==_0x2d4946('0x2f')){const _0x2b8b37={};return _0x2b8b37[_0x5afcd1[_0x2d4946('0x14')]]={[Op[_0x2d4946('0x27')]]:'%'+_0x399a2e['query']['filter']+'%'},_0x2b8b37;}})}));_0x243b28=_['merge']({},_0x243b28,_0x399a2e[_0x3f94cb('0x2b')]);const _0x21bde2={'where':_0x243b28[_0x3f94cb('0x2d')]};return db[_0x3f94cb('0x19')][_0x3f94cb('0x1b')](_0x21bde2)[_0x3f94cb('0x1f')](function(_0x1ef6a5){const _0xe1ca0e=_0x3f94cb;return _0x40e16b[_0xe1ca0e('0x1b')]=_0x1ef6a5,_0x399a2e['query'][_0xe1ca0e('0xc')]&&(_0x243b28[_0xe1ca0e('0x2a')]=[{'all':!![]}]),db[_0xe1ca0e('0x19')][_0xe1ca0e('0x34')](_0x243b28);})[_0x3f94cb('0x1f')](function(_0x35e520){const _0x4e0d5e=_0x3f94cb;return _0x40e16b[_0x4e0d5e('0x1a')]=_0x35e520,_0x40e16b;})['then'](respondWithFilteredResult(_0x23f1b1,_0x243b28))['catch'](handleError(_0x23f1b1,null));},exports[_0x3f0a54('0x33')]=function(_0x177cb0,_0x34ab4f){const _0x24d128=_0x3f0a54;let _0x432a9c={'raw':!![],'where':{'id':_0x177cb0[_0x24d128('0x20')]['id']}};const _0x397179={};return _0x397179['model']=_[_0x24d128('0x2c')](db[_0x24d128('0x19')][_0x24d128('0x28')]),_0x397179[_0x24d128('0x13')]=_[_0x24d128('0x2c')](_0x177cb0[_0x24d128('0x13')]),_0x397179[_0x24d128('0x32')]=_['intersection'](_0x397179[_0x24d128('0x1d')],_0x397179[_0x24d128('0x13')]),_0x432a9c['attributes']=_[_0x24d128('0x2')](_0x397179[_0x24d128('0x1d')],qs['fields'](_0x177cb0['query'][_0x24d128('0x35')])),_0x432a9c[_0x24d128('0xd')]=_0x432a9c[_0x24d128('0xd')][_0x24d128('0x17')]?_0x432a9c['attributes']:_0x397179['model'],_0x177cb0[_0x24d128('0x13')][_0x24d128('0xc')]&&(_0x432a9c[_0x24d128('0x2a')]=[{'all':!![]}]),_0x432a9c=_[_0x24d128('0x21')]({},_0x432a9c,_0x177cb0[_0x24d128('0x2b')]),db[_0x24d128('0x19')][_0x24d128('0x9')](_0x432a9c)[_0x24d128('0x1f')](handleEntityNotFound(_0x34ab4f,null))[_0x24d128('0x1f')](respondWithResult(_0x34ab4f,null))['catch'](handleError(_0x34ab4f,null));},exports['create']=function(_0x4a9a9c,_0x1093b3){const _0x127a10=_0x3f0a54;return db['JscriptyAnswerReport'][_0x127a10('0x10')](_0x4a9a9c['body'],{})[_0x127a10('0x1f')](respondWithResult(_0x1093b3,0xc9))[_0x127a10('0x2e')](handleError(_0x1093b3,null));},exports[_0x3f0a54('0x22')]=function(_0x15d994,_0x345c21){const _0x3afab0=_0x3f0a54;return _0x15d994[_0x3afab0('0x1c')]['id']&&delete _0x15d994[_0x3afab0('0x1c')]['id'],db[_0x3afab0('0x19')][_0x3afab0('0x9')]({'where':{'id':_0x15d994[_0x3afab0('0x20')]['id']}})['then'](handleEntityNotFound(_0x345c21,null))['then'](saveUpdates(_0x15d994[_0x3afab0('0x1c')],null))['then'](respondWithResult(_0x345c21,null))[_0x3afab0('0x2e')](handleError(_0x345c21,null));},exports[_0x3f0a54('0x30')]=function(_0x3dc728,_0x464a15){const _0x4d86ff=_0x3f0a54;return db['JscriptyAnswerReport'][_0x4d86ff('0x9')]({'where':{'id':_0x3dc728[_0x4d86ff('0x20')]['id']}})['then'](handleEntityNotFound(_0x464a15,null))['then'](removeEntity(_0x464a15,null))[_0x4d86ff('0x2e')](handleError(_0x464a15,null));},exports[_0x3f0a54('0x29')]=function(_0x1f41f5,_0x3e67c3){const _0xd920f4=_0x3f0a54;return db[_0xd920f4('0x19')]['describe']()[_0xd920f4('0x1f')](respondWithResult(_0x3e67c3,null))[_0xd920f4('0x2e')](handleError(_0x3e67c3,null));};