2b5daf17272e0175f4d0cd58c05b38f40de2c2ba
[motion-next.git] / server / api / analyticTreeReport / analyticTreeReport.controller.js
1 const a25_0x2726=['json','fieldName','order','key','nolimit','stack','error','pick','name','where','body','sequelize','findAll','status','update','query','send','map','destroy','options','../../mysqldb','includeAll','count','like','offset','intersection','catch','findOne','keys','include','merge','fields','sort','create','lodash','filters','model','params','then','limit','AnalyticTreeReport','set','type','rawAttributes','Content-Range','filter','attributes','show','../../components/parsers/qs'];(function(_0x3c5988,_0x2726a1){const _0x366603=function(_0x5ea575){while(--_0x5ea575){_0x3c5988['push'](_0x3c5988['shift']());}};_0x366603(++_0x2726a1);}(a25_0x2726,0x90));const a25_0x3666=function(_0x3c5988,_0x2726a1){_0x3c5988=_0x3c5988-0x0;let _0x366603=a25_0x2726[_0x3c5988];return _0x366603;};const _0x57f15c=a25_0x3666;'use strict';const _=require(_0x57f15c('0x25')),qs=require(_0x57f15c('0x2')),logger=require('../../config/logger')('api'),db=require(_0x57f15c('0x17'))['db'],{Op}=require(_0x57f15c('0xe'));function respondWithResult(_0x5ea575,_0x2e4f1d){return _0x2e4f1d=_0x2e4f1d||0xc8,function(_0x1339b0){const _0x333727=a25_0x3666;if(_0x1339b0)return _0x5ea575[_0x333727('0x10')](_0x2e4f1d)[_0x333727('0x3')](_0x1339b0);};}function respondWithFilteredResult(_0x5a4e07,_0x33f618){return function(_0x13c96c){const _0x2ed94b=a25_0x3666;if(_0x13c96c){const _0x1fc566=_0x13c96c[_0x2ed94b('0x19')],_0x2a1862=_0x33f618['offset'];let _0x5afc83=_0x33f618[_0x2ed94b('0x1b')]+_0x33f618[_0x2ed94b('0x2a')],_0x44fc23;return _0x5afc83>=_0x1fc566?(_0x5afc83=_0x1fc566,_0x44fc23=0xc8):_0x44fc23=0xce,_0x5a4e07[_0x2ed94b('0x10')](_0x44fc23),_0x5a4e07[_0x2ed94b('0x2c')](_0x2ed94b('0x2f'),_0x2a1862+'-'+_0x5afc83+'/'+_0x1fc566)[_0x2ed94b('0x3')](_0x13c96c);}return null;};}function saveUpdates(_0x11f4d5){return function(_0x40936e){const _0x1993a0=a25_0x3666;if(_0x40936e)return _0x40936e[_0x1993a0('0x11')](_0x11f4d5)[_0x1993a0('0x29')](function(_0x45484e){return _0x45484e;});return null;};}function removeEntity(_0x335d13){return function(_0x161ec6){if(_0x161ec6)return _0x161ec6['destroy']()['then'](function(){const _0x320946=a25_0x3666;_0x335d13[_0x320946('0x10')](0xcc)['end']();});};}function handleEntityNotFound(_0x49c773){return function(_0x5f1a8e){return!_0x5f1a8e&&_0x49c773['sendStatus'](0x194),_0x5f1a8e;};}function handleError(_0x259b90,_0x5c2e3a){return _0x5c2e3a=_0x5c2e3a||0x1f4,function(_0x3949e1){const _0x575459=a25_0x3666;logger[_0x575459('0x9')](_0x3949e1[_0x575459('0x8')]),_0x3949e1[_0x575459('0xb')]&&delete _0x3949e1[_0x575459('0xb')],_0x259b90[_0x575459('0x10')](_0x5c2e3a)[_0x575459('0x13')](_0x3949e1);};}exports['index']=function(_0x230a32,_0x7105b3){const _0x49d448=_0x57f15c;let _0x35c99d={};const _0xc9832={},_0x336929={'count':0x0,'rows':[]},_0x413a00=_[_0x49d448('0x14')](db[_0x49d448('0x2b')]['rawAttributes'],function(_0xde91ba){const _0x13f90b=_0x49d448;return{'name':_0xde91ba[_0x13f90b('0x4')],'type':_0xde91ba[_0x13f90b('0x2d')][_0x13f90b('0x6')]};});_0xc9832[_0x49d448('0x27')]=_['map'](_0x413a00,_0x49d448('0xb')),_0xc9832[_0x49d448('0x12')]=_[_0x49d448('0x1f')](_0x230a32[_0x49d448('0x12')]),_0xc9832[_0x49d448('0x26')]=_[_0x49d448('0x1c')](_0xc9832[_0x49d448('0x27')],_0xc9832[_0x49d448('0x12')]),_0x35c99d[_0x49d448('0x0')]=_[_0x49d448('0x1c')](_0xc9832['model'],qs['fields'](_0x230a32[_0x49d448('0x12')][_0x49d448('0x22')])),_0x35c99d[_0x49d448('0x0')]=_0x35c99d[_0x49d448('0x0')]['length']?_0x35c99d[_0x49d448('0x0')]:_0xc9832[_0x49d448('0x27')];typeof _0x230a32[_0x49d448('0x12')][_0x49d448('0x7')]==='undefined'&&(_0x35c99d[_0x49d448('0x2a')]=qs['limit'](_0x230a32['query']['limit']),_0x35c99d[_0x49d448('0x1b')]=qs[_0x49d448('0x1b')](_0x230a32[_0x49d448('0x12')][_0x49d448('0x1b')]));_0x35c99d[_0x49d448('0x5')]=qs[_0x49d448('0x23')](_0x230a32[_0x49d448('0x12')][_0x49d448('0x23')]),_0x35c99d[_0x49d448('0xc')]=qs[_0x49d448('0x26')](_[_0x49d448('0xa')](_0x230a32[_0x49d448('0x12')],_0xc9832[_0x49d448('0x26')]),_0x413a00);_0x230a32[_0x49d448('0x12')][_0x49d448('0x30')]&&(_0x35c99d[_0x49d448('0xc')]=_[_0x49d448('0x21')](_0x35c99d['where'],{[Op['or']]:_[_0x49d448('0x14')](_0x413a00,function(_0xc38405){const _0x15e3cc=_0x49d448;if(_0xc38405[_0x15e3cc('0x2d')]!=='VIRTUAL'){const _0x15e810={};return _0x15e810[_0xc38405[_0x15e3cc('0xb')]]={[Op[_0x15e3cc('0x1a')]]:'%'+_0x230a32['query'][_0x15e3cc('0x30')]+'%'},_0x15e810;}})}));_0x35c99d=_[_0x49d448('0x21')]({},_0x35c99d,_0x230a32[_0x49d448('0x16')]);const _0x5d239b={'where':_0x35c99d[_0x49d448('0xc')]};return db[_0x49d448('0x2b')][_0x49d448('0x19')](_0x5d239b)['then'](function(_0x404011){const _0x5d9ed5=_0x49d448;return _0x336929[_0x5d9ed5('0x19')]=_0x404011,_0x230a32['query'][_0x5d9ed5('0x18')]&&(_0x35c99d[_0x5d9ed5('0x20')]=[{'all':!![]}]),db[_0x5d9ed5('0x2b')][_0x5d9ed5('0xf')](_0x35c99d);})[_0x49d448('0x29')](function(_0x3718f6){return _0x336929['rows']=_0x3718f6,_0x336929;})[_0x49d448('0x29')](respondWithFilteredResult(_0x7105b3,_0x35c99d))[_0x49d448('0x1d')](handleError(_0x7105b3,null));},exports[_0x57f15c('0x1')]=function(_0x4f0216,_0x4b8469){const _0x38a544=_0x57f15c;let _0x4cfede={'raw':!![],'where':{'id':_0x4f0216[_0x38a544('0x28')]['id']}};const _0x32b662={};return _0x32b662['model']=_['keys'](db['AnalyticTreeReport'][_0x38a544('0x2e')]),_0x32b662[_0x38a544('0x12')]=_[_0x38a544('0x1f')](_0x4f0216[_0x38a544('0x12')]),_0x32b662[_0x38a544('0x26')]=_[_0x38a544('0x1c')](_0x32b662[_0x38a544('0x27')],_0x32b662[_0x38a544('0x12')]),_0x4cfede['attributes']=_[_0x38a544('0x1c')](_0x32b662[_0x38a544('0x27')],qs['fields'](_0x4f0216[_0x38a544('0x12')][_0x38a544('0x22')])),_0x4cfede[_0x38a544('0x0')]=_0x4cfede[_0x38a544('0x0')]['length']?_0x4cfede[_0x38a544('0x0')]:_0x32b662[_0x38a544('0x27')],_0x4f0216[_0x38a544('0x12')][_0x38a544('0x18')]&&(_0x4cfede[_0x38a544('0x20')]=[{'all':!![]}]),_0x4cfede=_[_0x38a544('0x21')]({},_0x4cfede,_0x4f0216[_0x38a544('0x16')]),db[_0x38a544('0x2b')][_0x38a544('0x1e')](_0x4cfede)[_0x38a544('0x29')](handleEntityNotFound(_0x4b8469,null))[_0x38a544('0x29')](respondWithResult(_0x4b8469,null))[_0x38a544('0x1d')](handleError(_0x4b8469,null));},exports[_0x57f15c('0x24')]=function(_0x1d1ea2,_0x30fad9){const _0x4addfc=_0x57f15c;return db[_0x4addfc('0x2b')][_0x4addfc('0x24')](_0x1d1ea2[_0x4addfc('0xd')],{})[_0x4addfc('0x29')](respondWithResult(_0x30fad9,0xc9))[_0x4addfc('0x1d')](handleError(_0x30fad9,null));},exports[_0x57f15c('0x11')]=function(_0x2278dc,_0x209a20){const _0x1144e3=_0x57f15c;return _0x2278dc[_0x1144e3('0xd')]['id']&&delete _0x2278dc[_0x1144e3('0xd')]['id'],db['AnalyticTreeReport'][_0x1144e3('0x1e')]({'where':{'id':_0x2278dc['params']['id']}})['then'](handleEntityNotFound(_0x209a20,null))['then'](saveUpdates(_0x2278dc[_0x1144e3('0xd')],null))[_0x1144e3('0x29')](respondWithResult(_0x209a20,null))[_0x1144e3('0x1d')](handleError(_0x209a20,null));},exports[_0x57f15c('0x15')]=function(_0x76ca6a,_0x57d6a3){const _0x559f02=_0x57f15c;return db[_0x559f02('0x2b')][_0x559f02('0x1e')]({'where':{'id':_0x76ca6a[_0x559f02('0x28')]['id']}})[_0x559f02('0x29')](handleEntityNotFound(_0x57d6a3,null))[_0x559f02('0x29')](removeEntity(_0x57d6a3,null))[_0x559f02('0x1d')](handleError(_0x57d6a3,null));};