Built motion from commit b517aaa2a6638133380e4d135c64a80893061362. Version 3.0.0...
[motion-next.git] / server / api / analyticFieldReport / analyticFieldReport.controller.js
1 const a17_0x4f20=['filters','error','stack','options','lodash','attributes','merge','sort','body','addFields','type','../../mysqldb','includeAll','catch','model','AnalyticFieldReport','params','end','transaction','then','findOne','sequelize','count','json','fields','key','undefined','sendStatus','findAll','AnalyticCustomReport','intersection','order','update','create','map','bulkCreate','set','api','name','rawAttributes','limit','offset','keys','length','VIRTUAL','status','index','query','ids','where','CustomReportId','pick','filter','destroy','fieldName','like'];(function(_0x771280,_0x4f2015){const _0x140ae9=function(_0x265dfb){while(--_0x265dfb){_0x771280['push'](_0x771280['shift']());}};_0x140ae9(++_0x4f2015);}(a17_0x4f20,0x89));const a17_0x140a=function(_0x771280,_0x4f2015){_0x771280=_0x771280-0x0;let _0x140ae9=a17_0x4f20[_0x771280];return _0x140ae9;};const _0x49cd66=a17_0x140a;'use strict';const _=require(_0x49cd66('0x23')),qs=require('../../components/parsers/qs'),logger=require('../../config/logger')(_0x49cd66('0xc')),db=require(_0x49cd66('0x2a'))['db'],{Op}=require(_0x49cd66('0x34'));function respondWithResult(_0x265dfb,_0x1cef77){return _0x1cef77=_0x1cef77||0xc8,function(_0x2af0dc){const _0x523726=a17_0x140a;if(_0x2af0dc)return _0x265dfb[_0x523726('0x14')](_0x1cef77)['json'](_0x2af0dc);};}function respondWithFilteredResult(_0x4f9aa8,_0xa1ba58){return function(_0xfad852){const _0x218cf7=a17_0x140a;if(_0xfad852){const _0x216894=_0xfad852[_0x218cf7('0x35')],_0x1f39b5=_0xa1ba58[_0x218cf7('0x10')];let _0x33fae5=_0xa1ba58['offset']+_0xa1ba58[_0x218cf7('0xf')],_0x269afe;return _0x33fae5>=_0x216894?(_0x33fae5=_0x216894,_0x269afe=0xc8):_0x269afe=0xce,_0x4f9aa8[_0x218cf7('0x14')](_0x269afe),_0x4f9aa8[_0x218cf7('0xb')]('Content-Range',_0x1f39b5+'-'+_0x33fae5+'/'+_0x216894)[_0x218cf7('0x36')](_0xfad852);}return null;};}function saveUpdates(_0x32eed9){return function(_0x4f541a){const _0x58faf9=a17_0x140a;if(_0x4f541a)return _0x4f541a[_0x58faf9('0x7')](_0x32eed9)['then'](function(_0x59ae56){return _0x59ae56;});return null;};}function removeEntity(_0x4ad3d6){return function(_0x24f85b){const _0x4b6613=a17_0x140a;if(_0x24f85b)return _0x24f85b[_0x4b6613('0x1c')]()[_0x4b6613('0x32')](function(){const _0x172993=_0x4b6613;_0x4ad3d6[_0x172993('0x14')](0xcc)[_0x172993('0x30')]();});};}function handleEntityNotFound(_0x25f17f){return function(_0x1be8f5){const _0x483369=a17_0x140a;return!_0x1be8f5&&_0x25f17f[_0x483369('0x2')](0x194),_0x1be8f5;};}function handleError(_0xb66ddb,_0x57c885){return _0x57c885=_0x57c885||0x1f4,function(_0x30032a){const _0x12bcea=a17_0x140a;logger[_0x12bcea('0x20')](_0x30032a[_0x12bcea('0x21')]),_0x30032a['name']&&delete _0x30032a[_0x12bcea('0xd')],_0xb66ddb[_0x12bcea('0x14')](_0x57c885)['send'](_0x30032a);};}exports[_0x49cd66('0x15')]=function(_0x27479e,_0xe70283){const _0xddae66=_0x49cd66;let _0xb4489f={};const _0x40e88b={},_0x1358f4={'count':0x0,'rows':[]},_0x10f6f5=_['map'](db[_0xddae66('0x2e')]['rawAttributes'],function(_0x2a9220){const _0x500263=_0xddae66;return{'name':_0x2a9220[_0x500263('0x1d')],'type':_0x2a9220[_0x500263('0x29')][_0x500263('0x0')]};});_0x40e88b[_0xddae66('0x2d')]=_[_0xddae66('0x9')](_0x10f6f5,_0xddae66('0xd')),_0x40e88b['query']=_[_0xddae66('0x11')](_0x27479e['query']),_0x40e88b[_0xddae66('0x1f')]=_[_0xddae66('0x5')](_0x40e88b[_0xddae66('0x2d')],_0x40e88b['query']),_0xb4489f[_0xddae66('0x24')]=_['intersection'](_0x40e88b['model'],qs[_0xddae66('0x37')](_0x27479e[_0xddae66('0x16')][_0xddae66('0x37')])),_0xb4489f['attributes']=_0xb4489f['attributes'][_0xddae66('0x12')]?_0xb4489f[_0xddae66('0x24')]:_0x40e88b[_0xddae66('0x2d')];typeof _0x27479e['query']['nolimit']===_0xddae66('0x1')&&(_0xb4489f[_0xddae66('0xf')]=qs[_0xddae66('0xf')](_0x27479e[_0xddae66('0x16')][_0xddae66('0xf')]),_0xb4489f[_0xddae66('0x10')]=qs['offset'](_0x27479e[_0xddae66('0x16')][_0xddae66('0x10')]));_0xb4489f[_0xddae66('0x6')]=qs[_0xddae66('0x26')](_0x27479e['query'][_0xddae66('0x26')]),_0xb4489f[_0xddae66('0x18')]=qs[_0xddae66('0x1f')](_[_0xddae66('0x1a')](_0x27479e[_0xddae66('0x16')],_0x40e88b[_0xddae66('0x1f')]),_0x10f6f5);_0x27479e[_0xddae66('0x16')]['filter']&&(_0xb4489f[_0xddae66('0x18')]=_['merge'](_0xb4489f[_0xddae66('0x18')],{[Op['or']]:_[_0xddae66('0x9')](_0x10f6f5,function(_0x51bbdc){const _0x4165c1=_0xddae66;if(_0x51bbdc[_0x4165c1('0x29')]!==_0x4165c1('0x13')){const _0x40ff84={};return _0x40ff84[_0x51bbdc[_0x4165c1('0xd')]]={[Op[_0x4165c1('0x1e')]]:'%'+_0x27479e[_0x4165c1('0x16')][_0x4165c1('0x1b')]+'%'},_0x40ff84;}})}));_0xb4489f=_[_0xddae66('0x25')]({},_0xb4489f,_0x27479e['options']);const _0x16cd40={'where':_0xb4489f[_0xddae66('0x18')]};return db[_0xddae66('0x2e')]['count'](_0x16cd40)[_0xddae66('0x32')](function(_0x387b9f){const _0x4af2fd=_0xddae66;return _0x1358f4[_0x4af2fd('0x35')]=_0x387b9f,_0x27479e[_0x4af2fd('0x16')][_0x4af2fd('0x2b')]&&(_0xb4489f['include']=[{'all':!![]}]),db[_0x4af2fd('0x2e')]['findAll'](_0xb4489f);})[_0xddae66('0x32')](function(_0x7d6f00){return _0x1358f4['rows']=_0x7d6f00,_0x1358f4;})[_0xddae66('0x32')](respondWithFilteredResult(_0xe70283,_0xb4489f))[_0xddae66('0x2c')](handleError(_0xe70283,null));},exports['show']=function(_0x66cc77,_0x3ea7e3){const _0x49fcd9=_0x49cd66;let _0x1df980={'raw':![],'where':{'id':_0x66cc77[_0x49fcd9('0x2f')]['id']}};const _0x26d719={};return _0x26d719[_0x49fcd9('0x2d')]=_['keys'](db['AnalyticFieldReport'][_0x49fcd9('0xe')]),_0x26d719[_0x49fcd9('0x16')]=_['keys'](_0x66cc77[_0x49fcd9('0x16')]),_0x26d719[_0x49fcd9('0x1f')]=_['intersection'](_0x26d719[_0x49fcd9('0x2d')],_0x26d719[_0x49fcd9('0x16')]),_0x1df980[_0x49fcd9('0x24')]=_['intersection'](_0x26d719['model'],qs[_0x49fcd9('0x37')](_0x66cc77[_0x49fcd9('0x16')]['fields'])),_0x1df980['attributes']=_0x1df980[_0x49fcd9('0x24')][_0x49fcd9('0x12')]?_0x1df980['attributes']:_0x26d719[_0x49fcd9('0x2d')],_0x66cc77[_0x49fcd9('0x16')][_0x49fcd9('0x2b')]&&(_0x1df980['include']=[{'all':!![]}]),_0x1df980=_[_0x49fcd9('0x25')]({},_0x1df980,_0x66cc77[_0x49fcd9('0x22')]),db['AnalyticFieldReport']['findOne'](_0x1df980)[_0x49fcd9('0x32')](handleEntityNotFound(_0x3ea7e3,null))[_0x49fcd9('0x32')](respondWithResult(_0x3ea7e3,null))[_0x49fcd9('0x2c')](handleError(_0x3ea7e3,null));},exports[_0x49cd66('0x8')]=function(_0x4e9b96,_0x4015a9){const _0x28954b=_0x49cd66;return db[_0x28954b('0x2e')][_0x28954b('0x8')](_0x4e9b96[_0x28954b('0x27')],{})[_0x28954b('0x32')](respondWithResult(_0x4015a9,0xc9))[_0x28954b('0x2c')](handleError(_0x4015a9,null));},exports[_0x49cd66('0xa')]=function(_0x429560,_0x1b960f){const _0x2f628e=_0x49cd66;return db['AnalyticFieldReport'][_0x2f628e('0xa')](_0x429560[_0x2f628e('0x27')],{'raw':![],'individualHooks':!![]})[_0x2f628e('0x32')](respondWithResult(_0x1b960f,0xc9))[_0x2f628e('0x2c')](handleError(_0x1b960f,null));},exports[_0x49cd66('0x7')]=function(_0x1d3d5c,_0x314b24){const _0x8fa2c=_0x49cd66;return _0x1d3d5c[_0x8fa2c('0x27')]['id']&&delete _0x1d3d5c[_0x8fa2c('0x27')]['id'],db[_0x8fa2c('0x2e')][_0x8fa2c('0x33')]({'where':{'id':_0x1d3d5c[_0x8fa2c('0x2f')]['id']}})[_0x8fa2c('0x32')](handleEntityNotFound(_0x314b24,null))['then'](saveUpdates(_0x1d3d5c[_0x8fa2c('0x27')],null))[_0x8fa2c('0x32')](respondWithResult(_0x314b24,null))[_0x8fa2c('0x2c')](handleError(_0x314b24,null));},exports['destroy']=function(_0x42c59a,_0x4c7b6e){const _0x4e0c73=_0x49cd66;return db[_0x4e0c73('0x2e')][_0x4e0c73('0x33')]({'where':{'id':_0x42c59a['params']['id']}})[_0x4e0c73('0x32')](handleEntityNotFound(_0x4c7b6e,null))[_0x4e0c73('0x32')](removeEntity(_0x4c7b6e,null))['catch'](handleError(_0x4c7b6e,null));},exports['bulkDestroy']=function(_0x2e92d3,_0x35fc86){const _0xade140=_0x49cd66;return db['AnalyticFieldReport']['destroy']({'where':{'id':_0x2e92d3['query'][_0xade140('0x17')]||[]},'raw':![],'individualHooks':!![]})['then'](respondWithResult(_0x35fc86,0xcc))['catch'](handleError(_0x35fc86,null));},exports[_0x49cd66('0x28')]=function(_0x2b6aae,_0x1aa2b9){const _0x3b10ea=_0x49cd66;return db[_0x3b10ea('0x4')][_0x3b10ea('0x33')]({'where':{'id':_0x2b6aae[_0x3b10ea('0x2f')]['id']}})['then'](handleEntityNotFound(_0x1aa2b9,null))['then'](function(_0xbcf641){const _0x44f653=_0x3b10ea;if(_0xbcf641)return db[_0x44f653('0x34')][_0x44f653('0x31')](function(_0x467108){const _0x23c1bb=_0x44f653;return db['AnalyticFieldReport'][_0x23c1bb('0x1c')]({'where':{'CustomReportId':_0x2b6aae[_0x23c1bb('0x2f')]['id']},'transaction':_0x467108})['then'](function(){const _0x1baaec=_0x23c1bb,_0x2a99dd=_[_0x1baaec('0x9')](_0x2b6aae[_0x1baaec('0x27')],function(_0x36be94){const _0x28a6e9=_0x1baaec;return delete _0x36be94['id'],_0x36be94[_0x28a6e9('0x19')]=_0x2b6aae[_0x28a6e9('0x2f')]['id'],_0x36be94;});return db['AnalyticFieldReport'][_0x1baaec('0xa')](_0x2a99dd,{'transaction':_0x467108});});})[_0x44f653('0x32')](function(){const _0x532b2d=_0x44f653;return db[_0x532b2d('0x2e')][_0x532b2d('0x3')]({'where':{'CustomReportId':_0x2b6aae[_0x532b2d('0x2f')]['id']}});});})[_0x3b10ea('0x32')](respondWithResult(_0x1aa2b9,null))[_0x3b10ea('0x2c')](handleError(_0x1aa2b9,null));};