477374d3f1d204ecaef3a988b2435cb904f717c4
[motion-next.git] / server / api / jscriptyAnswerReport / jscriptyAnswerReport.controller.js
1 const a374_0x403f=['rawAttributes','findOne','merge','model','params','keys','findAll','end','filters','name','include','VIRTUAL','body','destroy','index','map','query','intersection','fieldName','../../mysqldb','count','attributes','sequelize','set','error','pick','catch','filter','where','show','send','stack','create','sort','../../components/parsers/qs','undefined','order','type','limit','rows','options','fields','json','key','like','then','JscriptyAnswerReport','includeAll','describe','length','status','Content-Range','offset','../../config/logger'];(function(_0x401fbb,_0x403fd9){const _0x150d3e=function(_0x5b078a){while(--_0x5b078a){_0x401fbb['push'](_0x401fbb['shift']());}};_0x150d3e(++_0x403fd9);}(a374_0x403f,0x1ec));const a374_0x150d=function(_0x401fbb,_0x403fd9){_0x401fbb=_0x401fbb-0x0;let _0x150d3e=a374_0x403f[_0x401fbb];return _0x150d3e;};const _0x40cfef=a374_0x150d;'use strict';const _=require('lodash'),qs=require(_0x40cfef('0x1c')),logger=require(_0x40cfef('0x2f'))('api'),db=require(_0x40cfef('0xd'))['db'],{Op}=require(_0x40cfef('0x10'));function respondWithResult(_0x5b078a,_0x52f7c3){return _0x52f7c3=_0x52f7c3||0xc8,function(_0x1c7e0a){const _0x30a828=a374_0x150d;if(_0x1c7e0a)return _0x5b078a[_0x30a828('0x2c')](_0x52f7c3)[_0x30a828('0x24')](_0x1c7e0a);};}function respondWithFilteredResult(_0x3dab2a,_0x46502f){return function(_0x5f3ffb){const _0x339eeb=a374_0x150d;if(_0x5f3ffb){const _0x566cf8=_0x5f3ffb[_0x339eeb('0xe')],_0x20208d=_0x46502f[_0x339eeb('0x2e')];let _0x2140de=_0x46502f['offset']+_0x46502f[_0x339eeb('0x20')],_0x18c9c6;return _0x2140de>=_0x566cf8?(_0x2140de=_0x566cf8,_0x18c9c6=0xc8):_0x18c9c6=0xce,_0x3dab2a[_0x339eeb('0x2c')](_0x18c9c6),_0x3dab2a[_0x339eeb('0x11')](_0x339eeb('0x2d'),_0x20208d+'-'+_0x2140de+'/'+_0x566cf8)[_0x339eeb('0x24')](_0x5f3ffb);}return null;};}function saveUpdates(_0x523f59){return function(_0x14778f){if(_0x14778f)return _0x14778f['update'](_0x523f59)['then'](function(_0x542c95){return _0x542c95;});return null;};}function removeEntity(_0x5ea054){return function(_0x12203e){const _0x43e582=a374_0x150d;if(_0x12203e)return _0x12203e[_0x43e582('0x7')]()[_0x43e582('0x27')](function(){const _0x262dc9=_0x43e582;_0x5ea054[_0x262dc9('0x2c')](0xcc)[_0x262dc9('0x1')]();});};}function handleEntityNotFound(_0x303dc3){return function(_0x51be7b){return!_0x51be7b&&_0x303dc3['sendStatus'](0x194),_0x51be7b;};}function handleError(_0x3a19a8,_0x1c9260){return _0x1c9260=_0x1c9260||0x1f4,function(_0x4f76ba){const _0x195c4f=a374_0x150d;logger[_0x195c4f('0x12')](_0x4f76ba[_0x195c4f('0x19')]),_0x4f76ba[_0x195c4f('0x3')]&&delete _0x4f76ba[_0x195c4f('0x3')],_0x3a19a8[_0x195c4f('0x2c')](_0x1c9260)[_0x195c4f('0x18')](_0x4f76ba);};}exports[_0x40cfef('0x8')]=function(_0x45fd1a,_0x24c79a){const _0x48cc79=_0x40cfef;let _0xee7f25={};const _0x28408f={},_0x828ebb={'count':0x0,'rows':[]},_0x26de14=_[_0x48cc79('0x9')](db[_0x48cc79('0x28')][_0x48cc79('0x30')],function(_0x30d9c7){const _0x14f9f6=_0x48cc79;return{'name':_0x30d9c7[_0x14f9f6('0xc')],'type':_0x30d9c7[_0x14f9f6('0x1f')][_0x14f9f6('0x25')]};});_0x28408f[_0x48cc79('0x33')]=_['map'](_0x26de14,'name'),_0x28408f['query']=_[_0x48cc79('0x35')](_0x45fd1a[_0x48cc79('0xa')]),_0x28408f[_0x48cc79('0x2')]=_['intersection'](_0x28408f[_0x48cc79('0x33')],_0x28408f[_0x48cc79('0xa')]),_0xee7f25[_0x48cc79('0xf')]=_[_0x48cc79('0xb')](_0x28408f[_0x48cc79('0x33')],qs[_0x48cc79('0x23')](_0x45fd1a[_0x48cc79('0xa')][_0x48cc79('0x23')])),_0xee7f25[_0x48cc79('0xf')]=_0xee7f25[_0x48cc79('0xf')][_0x48cc79('0x2b')]?_0xee7f25[_0x48cc79('0xf')]:_0x28408f[_0x48cc79('0x33')];typeof _0x45fd1a[_0x48cc79('0xa')]['nolimit']===_0x48cc79('0x1d')&&(_0xee7f25[_0x48cc79('0x20')]=qs['limit'](_0x45fd1a['query'][_0x48cc79('0x20')]),_0xee7f25[_0x48cc79('0x2e')]=qs['offset'](_0x45fd1a[_0x48cc79('0xa')][_0x48cc79('0x2e')]));_0xee7f25[_0x48cc79('0x1e')]=qs[_0x48cc79('0x1b')](_0x45fd1a['query'][_0x48cc79('0x1b')]),_0xee7f25[_0x48cc79('0x16')]=qs[_0x48cc79('0x2')](_[_0x48cc79('0x13')](_0x45fd1a['query'],_0x28408f['filters']),_0x26de14);_0x45fd1a['query'][_0x48cc79('0x15')]&&(_0xee7f25[_0x48cc79('0x16')]=_[_0x48cc79('0x32')](_0xee7f25[_0x48cc79('0x16')],{[Op['or']]:_[_0x48cc79('0x9')](_0x26de14,function(_0x4c0af5){const _0x2b78a4=_0x48cc79;if(_0x4c0af5[_0x2b78a4('0x1f')]!==_0x2b78a4('0x5')){const _0x24522a={};return _0x24522a[_0x4c0af5[_0x2b78a4('0x3')]]={[Op[_0x2b78a4('0x26')]]:'%'+_0x45fd1a['query'][_0x2b78a4('0x15')]+'%'},_0x24522a;}})}));_0xee7f25=_['merge']({},_0xee7f25,_0x45fd1a[_0x48cc79('0x22')]);const _0x235914={'where':_0xee7f25['where']};return db[_0x48cc79('0x28')][_0x48cc79('0xe')](_0x235914)['then'](function(_0x4ee84b){const _0x47e7fb=_0x48cc79;return _0x828ebb[_0x47e7fb('0xe')]=_0x4ee84b,_0x45fd1a[_0x47e7fb('0xa')][_0x47e7fb('0x29')]&&(_0xee7f25[_0x47e7fb('0x4')]=[{'all':!![]}]),db[_0x47e7fb('0x28')][_0x47e7fb('0x0')](_0xee7f25);})[_0x48cc79('0x27')](function(_0x205974){const _0x7fa83f=_0x48cc79;return _0x828ebb[_0x7fa83f('0x21')]=_0x205974,_0x828ebb;})[_0x48cc79('0x27')](respondWithFilteredResult(_0x24c79a,_0xee7f25))[_0x48cc79('0x14')](handleError(_0x24c79a,null));},exports[_0x40cfef('0x17')]=function(_0x246f2e,_0x4b7151){const _0x15f625=_0x40cfef;let _0x2e0ace={'raw':!![],'where':{'id':_0x246f2e[_0x15f625('0x34')]['id']}};const _0x357aa9={};return _0x357aa9['model']=_[_0x15f625('0x35')](db[_0x15f625('0x28')][_0x15f625('0x30')]),_0x357aa9[_0x15f625('0xa')]=_[_0x15f625('0x35')](_0x246f2e[_0x15f625('0xa')]),_0x357aa9[_0x15f625('0x2')]=_[_0x15f625('0xb')](_0x357aa9[_0x15f625('0x33')],_0x357aa9[_0x15f625('0xa')]),_0x2e0ace['attributes']=_[_0x15f625('0xb')](_0x357aa9[_0x15f625('0x33')],qs[_0x15f625('0x23')](_0x246f2e[_0x15f625('0xa')][_0x15f625('0x23')])),_0x2e0ace[_0x15f625('0xf')]=_0x2e0ace[_0x15f625('0xf')][_0x15f625('0x2b')]?_0x2e0ace[_0x15f625('0xf')]:_0x357aa9[_0x15f625('0x33')],_0x246f2e[_0x15f625('0xa')]['includeAll']&&(_0x2e0ace[_0x15f625('0x4')]=[{'all':!![]}]),_0x2e0ace=_[_0x15f625('0x32')]({},_0x2e0ace,_0x246f2e[_0x15f625('0x22')]),db[_0x15f625('0x28')][_0x15f625('0x31')](_0x2e0ace)[_0x15f625('0x27')](handleEntityNotFound(_0x4b7151,null))[_0x15f625('0x27')](respondWithResult(_0x4b7151,null))['catch'](handleError(_0x4b7151,null));},exports['create']=function(_0x372994,_0x551862){const _0x1743f6=_0x40cfef;return db[_0x1743f6('0x28')][_0x1743f6('0x1a')](_0x372994[_0x1743f6('0x6')],{})[_0x1743f6('0x27')](respondWithResult(_0x551862,0xc9))[_0x1743f6('0x14')](handleError(_0x551862,null));},exports['update']=function(_0x8cc7e1,_0x790d1d){const _0x475c67=_0x40cfef;return _0x8cc7e1['body']['id']&&delete _0x8cc7e1[_0x475c67('0x6')]['id'],db[_0x475c67('0x28')][_0x475c67('0x31')]({'where':{'id':_0x8cc7e1[_0x475c67('0x34')]['id']}})['then'](handleEntityNotFound(_0x790d1d,null))[_0x475c67('0x27')](saveUpdates(_0x8cc7e1[_0x475c67('0x6')],null))[_0x475c67('0x27')](respondWithResult(_0x790d1d,null))[_0x475c67('0x14')](handleError(_0x790d1d,null));},exports[_0x40cfef('0x7')]=function(_0x2bb1cf,_0x31ef9f){const _0x1c75a6=_0x40cfef;return db[_0x1c75a6('0x28')][_0x1c75a6('0x31')]({'where':{'id':_0x2bb1cf[_0x1c75a6('0x34')]['id']}})[_0x1c75a6('0x27')](handleEntityNotFound(_0x31ef9f,null))[_0x1c75a6('0x27')](removeEntity(_0x31ef9f,null))['catch'](handleError(_0x31ef9f,null));},exports[_0x40cfef('0x2a')]=function(_0x5ebe56,_0x3c402d){const _0x170f5f=_0x40cfef;return db[_0x170f5f('0x28')]['describe']()[_0x170f5f('0x27')](respondWithResult(_0x3c402d,null))['catch'](handleError(_0x3c402d,null));};