Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / api / analyticDefaultReport / analyticDefaultReport.controller.js
index 9a1a9c3..cead3d6 100644 (file)
@@ -1 +1 @@
-const a11_0x55ce=['GROUP_CONCAT(%s)','VIRTUAL','rules','child_process','join','sendStatus','undefined','attributes','../../mysqldb','condition','default','AnalyticMetric','../../files/reports','alias','get','ROUND(%s)','send','squel','.createdAt\x20BETWEEN\x20?\x20AND\x20?','COUNT(%s)','keyBy','Please\x20insert\x20at\x20least\x20one\x20field','error','COUNT(DISTINCT\x20%s)','right_join','csv','findAll','MetricId','rows','filters','index','stack','order','replace','startDate','intersection','query','path','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','preview','joins','Limited\x20Query:','json','No\x20available\x20data','AVG(%s)','UserProfileResource','IS\x20NOT\x20EMPTY','DESC','role','parentKey','Unable\x20to\x20retrieve\x20the\x20current\x20user','findOne','table','update','AnalyticDefaultReport','%s-%s.%s','cross_join','includes','foreignKey','body','getFields','Run\x20Query:','length','merge','name','set','IS\x20EMPTY','rawAttributes','MIN(%s)','generate','MAX(%s)','from','includeAll','foreignTable','fields','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','end','include','format','filter','metric','create','field','endDate','conditions','show','model','dbH','%s.%s\x20=\x20%s.%s','limit','sequelize','catch','UNIX_TIMESTAMP(%s)','parse','QueryTypes','select','value','output','destroy','../../config/logger','params','IS\x20NOT\x20NULL','SELECT','api','type','status','groupBy','../../components/parsers/qs','where','keys','left_join','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','offset','HOUR(%s)','randomstring','count','DATE(%s)','IS\x20NULL','COUNT(*)','group','fullPath','savename','countTable','function','SUM(%s)','user','toString','debug','DefaultReports','sort','Reports','util','orderBy','then','like','options','UserProfileSection','lodash','SEC_TO_TIME(%s)','map','fork','operator'];(function(_0x278432,_0x168eea){const _0x55ce68=function(_0x91f87d){while(--_0x91f87d){_0x278432['push'](_0x278432['shift']());}};_0x55ce68(++_0x168eea);}(a11_0x55ce,0x132));const a11_0x91f8=function(_0x278432,_0x168eea){_0x278432=_0x278432-0xf8;let _0x55ce68=a11_0x55ce[_0x278432];return _0x55ce68;};const a11_0x51591f=a11_0x91f8;'use strict';const util=require(a11_0x51591f(0x165)),path=require(a11_0x51591f(0x107)),_=require(a11_0x51591f(0x16b)),squel=require(a11_0x51591f(0x181)),qs=require(a11_0x51591f(0x14d)),logger=require(a11_0x51591f(0x145))(a11_0x51591f(0x149)),{db}=require(a11_0x51591f(0x178)),dbH=require(a11_0x51591f(0x178))[a11_0x51591f(0x139)],{Op,ValidationErrorItem,QueryTypes}=require(a11_0x51591f(0x13c));function respondWithResult(_0x57b8e1,_0x21f805){return _0x21f805=_0x21f805||0xc8,function(_0x272daa){const _0x15bf69=a11_0x91f8;if(_0x272daa)return _0x57b8e1['status'](_0x21f805)[_0x15bf69(0x10c)](_0x272daa);};}function respondWithFilteredResult(_0x5969a6,_0x34cb45){return function(_0x24d693){const _0xe2b347=a11_0x91f8;if(_0x24d693){const _0x6a1f31=_0x24d693[_0xe2b347(0x155)],_0x758afb=_0x34cb45['offset'];let _0x3e5603=_0x34cb45[_0xe2b347(0x152)]+_0x34cb45[_0xe2b347(0x13b)],_0x3b702d;return _0x3e5603>=_0x6a1f31?(_0x3e5603=_0x6a1f31,_0x3b702d=0xc8):_0x3b702d=0xce,_0x5969a6[_0xe2b347(0x14b)](_0x3b702d),_0x5969a6[_0xe2b347(0x123)]('Content-Range',_0x758afb+'-'+_0x3e5603+'/'+_0x6a1f31)[_0xe2b347(0x10c)](_0x24d693);}return null;};}function saveUpdates(_0x9c0535){return function(_0x1a5c77){const _0x45433d=a11_0x91f8;if(_0x1a5c77)return _0x1a5c77[_0x45433d(0x117)](_0x9c0535)['then'](function(_0x48f345){return _0x48f345;});return null;};}function removeEntity(_0x2ef02b){return function(_0x438f52){const _0x4e90c4=a11_0x91f8;if(_0x438f52)return _0x438f52['destroy']()[_0x4e90c4(0x167)](function(){const _0x5b09b7=_0x4e90c4,_0x3aa84f=_0x438f52[_0x5b09b7(0x17e)]({'plain':!![]}),_0x41010e='DefaultReports';return db[_0x5b09b7(0x10f)][_0x5b09b7(0x144)]({'where':{'type':_0x41010e,'resourceId':_0x3aa84f['id']}})['then'](function(){return _0x438f52;});})[_0x4e90c4(0x167)](function(){const _0x5f1139=_0x4e90c4;_0x2ef02b['status'](0xcc)[_0x5f1139(0x12e)]();});};}function handleEntityNotFound(_0x5ee60a){return function(_0xe3efb8){const _0x267038=a11_0x91f8;return!_0xe3efb8&&_0x5ee60a[_0x267038(0x175)](0x194),_0xe3efb8;};}function handleError(_0x2e227f,_0x28c9c9){return _0x28c9c9=_0x28c9c9||0x1f4,function(_0x3bf423){const _0x4059eb=a11_0x91f8;logger[_0x4059eb(0xf8)](_0x3bf423[_0x4059eb(0x101)]),_0x3bf423[_0x4059eb(0x122)]&&delete _0x3bf423[_0x4059eb(0x122)],_0x2e227f[_0x4059eb(0x14b)](_0x28c9c9)[_0x4059eb(0x180)](_0x3bf423);};}exports[a11_0x51591f(0x100)]=function(_0x14dee1,_0x32b968){const _0x507879=a11_0x51591f;let _0x3fc729={};const _0x5d6b6e={},_0x1e8f67={'count':0x0,'rows':[]},_0x225fb1=_['map'](db['AnalyticDefaultReport'][_0x507879(0x125)],function(_0x461569){const _0x5706ad=_0x507879;return{'name':_0x461569['fieldName'],'type':_0x461569[_0x5706ad(0x14a)]['key']};});_0x5d6b6e['model']=_[_0x507879(0x16d)](_0x225fb1,_0x507879(0x122)),_0x5d6b6e[_0x507879(0x106)]=_[_0x507879(0x14f)](_0x14dee1[_0x507879(0x106)]),_0x5d6b6e[_0x507879(0xff)]=_['intersection'](_0x5d6b6e[_0x507879(0x138)],_0x5d6b6e[_0x507879(0x106)]),_0x3fc729[_0x507879(0x177)]=_['intersection'](_0x5d6b6e[_0x507879(0x138)],qs[_0x507879(0x12c)](_0x14dee1[_0x507879(0x106)][_0x507879(0x12c)])),_0x3fc729[_0x507879(0x177)]=_0x3fc729[_0x507879(0x177)][_0x507879(0x120)]?_0x3fc729[_0x507879(0x177)]:_0x5d6b6e['model'];typeof _0x14dee1[_0x507879(0x106)]['nolimit']===_0x507879(0x176)&&(_0x3fc729[_0x507879(0x13b)]=qs[_0x507879(0x13b)](_0x14dee1[_0x507879(0x106)]['limit']),_0x3fc729[_0x507879(0x152)]=qs[_0x507879(0x152)](_0x14dee1[_0x507879(0x106)][_0x507879(0x152)]));_0x3fc729[_0x507879(0x102)]=qs[_0x507879(0x163)](_0x14dee1['query'][_0x507879(0x163)]),_0x3fc729['where']=qs[_0x507879(0xff)](_['pick'](_0x14dee1[_0x507879(0x106)],_0x5d6b6e[_0x507879(0xff)]),_0x225fb1);_0x14dee1[_0x507879(0x106)]['filter']&&(_0x3fc729[_0x507879(0x14e)]=_['merge'](_0x3fc729[_0x507879(0x14e)],{[Op['or']]:_['map'](_0x225fb1,function(_0x5a22cc){const _0x142d03=_0x507879;if(_0x5a22cc[_0x142d03(0x14a)]!==_0x142d03(0x171)){const _0x568988={};return _0x568988[_0x5a22cc[_0x142d03(0x122)]]={[Op[_0x142d03(0x168)]]:'%'+_0x14dee1['query'][_0x142d03(0x131)]+'%'},_0x568988;}})}));_0x3fc729=_[_0x507879(0x121)]({},_0x3fc729,_0x14dee1[_0x507879(0x169)]);const _0x5e2d52={'where':_0x3fc729[_0x507879(0x14e)]};return db['AnalyticDefaultReport']['count'](_0x5e2d52)['then'](function(_0x422752){const _0x314954=_0x507879;return _0x1e8f67[_0x314954(0x155)]=_0x422752,_0x14dee1[_0x314954(0x106)][_0x314954(0x12a)]&&(_0x3fc729[_0x314954(0x12f)]=[{'all':!![]}]),db[_0x314954(0x118)]['findAll'](_0x3fc729);})[_0x507879(0x167)](function(_0x3d2cd4){const _0x4f3062=_0x507879;return _0x1e8f67[_0x4f3062(0xfe)]=_0x3d2cd4,_0x1e8f67;})[_0x507879(0x167)](respondWithFilteredResult(_0x32b968,_0x3fc729))[_0x507879(0x13d)](handleError(_0x32b968,null));},exports[a11_0x51591f(0x137)]=function(_0x30778e,_0x3f8340){const _0x57e248=a11_0x51591f;let _0x53b836={'raw':!![],'where':{'id':_0x30778e[_0x57e248(0x146)]['id']}};const _0x1a8e78={};return _0x1a8e78[_0x57e248(0x138)]=_[_0x57e248(0x14f)](db[_0x57e248(0x118)][_0x57e248(0x125)]),_0x1a8e78[_0x57e248(0x106)]=_[_0x57e248(0x14f)](_0x30778e[_0x57e248(0x106)]),_0x1a8e78[_0x57e248(0xff)]=_['intersection'](_0x1a8e78[_0x57e248(0x138)],_0x1a8e78[_0x57e248(0x106)]),_0x53b836[_0x57e248(0x177)]=_[_0x57e248(0x105)](_0x1a8e78['model'],qs[_0x57e248(0x12c)](_0x30778e[_0x57e248(0x106)]['fields'])),_0x53b836[_0x57e248(0x177)]=_0x53b836[_0x57e248(0x177)][_0x57e248(0x120)]?_0x53b836[_0x57e248(0x177)]:_0x1a8e78[_0x57e248(0x138)],_0x30778e[_0x57e248(0x106)][_0x57e248(0x12a)]&&(_0x53b836['include']=[{'all':!![]}]),_0x53b836=_[_0x57e248(0x121)]({},_0x53b836,_0x30778e['options']),db[_0x57e248(0x118)][_0x57e248(0x115)](_0x53b836)['then'](handleEntityNotFound(_0x3f8340,null))[_0x57e248(0x167)](respondWithResult(_0x3f8340,null))[_0x57e248(0x13d)](handleError(_0x3f8340,null));},exports[a11_0x51591f(0x133)]=function(_0x59a194,_0x4b72a0){const _0x399334=a11_0x51591f;return db[_0x399334(0x118)]['create'](_0x59a194['body'],{})[_0x399334(0x167)](function(_0x31d5b5){const _0x464027=_0x399334,_0x5cabc9=_0x59a194[_0x464027(0x15f)][_0x464027(0x17e)]({'plain':!![]});if(!_0x5cabc9)throw new Error(_0x464027(0x114));if(_0x5cabc9[_0x464027(0x112)]==='user'){const _0x425c0b=_0x31d5b5[_0x464027(0x17e)]({'plain':!![]}),_0x1e4cb0=_0x464027(0x164);return db[_0x464027(0x16a)]['findOne']({'where':{'name':_0x1e4cb0,'userProfileId':_0x5cabc9['userProfileId']},'raw':!![]})[_0x464027(0x167)](function(_0x34772e){const _0x55081a=_0x464027;return _0x34772e&&_0x34772e['autoAssociation']===0x0?db[_0x55081a(0x10f)]['create']({'name':_0x425c0b[_0x55081a(0x122)],'resourceId':_0x425c0b['id'],'type':_0x55081a(0x162),'sectionId':_0x34772e['id']},{})[_0x55081a(0x167)](function(){return _0x31d5b5;}):_0x31d5b5;})[_0x464027(0x13d)](function(_0x134cd6){const _0x225a9e=_0x464027;logger[_0x225a9e(0xf8)](_0x225a9e(0x108),_0x134cd6);throw _0x134cd6;});}return _0x31d5b5;})['then'](respondWithResult(_0x4b72a0,0xc9))['catch'](handleError(_0x4b72a0,null));},exports[a11_0x51591f(0x117)]=function(_0x562b16,_0x340772){const _0xfb61cf=a11_0x51591f;return _0x562b16[_0xfb61cf(0x11d)]['id']&&delete _0x562b16[_0xfb61cf(0x11d)]['id'],db[_0xfb61cf(0x118)]['findOne']({'where':{'id':_0x562b16[_0xfb61cf(0x146)]['id']}})['then'](handleEntityNotFound(_0x340772,null))[_0xfb61cf(0x167)](saveUpdates(_0x562b16[_0xfb61cf(0x11d)],null))[_0xfb61cf(0x167)](respondWithResult(_0x340772,null))[_0xfb61cf(0x13d)](handleError(_0x340772,null));},exports[a11_0x51591f(0x144)]=function(_0x3ac4ab,_0x1d84d7){const _0x1d6286=a11_0x51591f;return db['AnalyticDefaultReport'][_0x1d6286(0x115)]({'where':{'id':_0x3ac4ab[_0x1d6286(0x146)]['id']}})[_0x1d6286(0x167)](handleEntityNotFound(_0x1d84d7,null))[_0x1d6286(0x167)](removeEntity(_0x1d84d7,null))[_0x1d6286(0x13d)](handleError(_0x1d84d7,null));},exports[a11_0x51591f(0x109)]=function(_0x18862a,_0x161a14){const _0x373ebf=a11_0x51591f,_0x1d5ed9=0xa,_0xf75c77=[_0x373ebf(0x174),_0x373ebf(0x150),_0x373ebf(0xfa),_0x373ebf(0x11a)],_0x205097={'SUM':_0x373ebf(0x15e),'COUNT':_0x373ebf(0x183),'COUNT\x20DISTINCT':'COUNT(DISTINCT\x20%s)','MAX':_0x373ebf(0x128),'MIN':'MIN(%s)','AVG':_0x373ebf(0x10e),'GROUP_CONCAT':_0x373ebf(0x170),'GROUP_CONCAT\x20ASC':_0x373ebf(0x151),'GROUP_CONCAT\x20DESC':_0x373ebf(0x12d)},_0xd573f3={'SEC_TO_TIME':_0x373ebf(0x16c),'DATE':_0x373ebf(0x156),'HOUR':_0x373ebf(0x153),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x373ebf(0x13e)},_0x43f7aa=function(_0x412f2f){const _0x3a4410=_0x373ebf;return!_[_0x3a4410(0x11b)](['IS\x20NULL',_0x3a4410(0x147),_0x3a4410(0x124),_0x3a4410(0x110)],_0x412f2f);},_0x5ae1ce=function(_0x3da58b){const _0x44619e=_0x373ebf;if(!_0x3da58b||!_0x3da58b['rules']['length'])return'';let _0x50b30a='(';for(let _0x2bf2ee=0x0;_0x2bf2ee<_0x3da58b['rules'][_0x44619e(0x120)];_0x2bf2ee+=0x1){_0x2bf2ee>0x0&&(_0x50b30a+='\x20'+_0x3da58b[_0x44619e(0x16f)]+'\x20'),_0x50b30a+=_0x3da58b[_0x44619e(0x172)][_0x2bf2ee][_0x44619e(0x159)]?_0x5ae1ce(_0x3da58b[_0x44619e(0x172)][_0x2bf2ee][_0x44619e(0x159)]):_0x3da58b[_0x44619e(0x172)][_0x2bf2ee]['field']+'\x20'+_0x3da58b['rules'][_0x2bf2ee]['condition']+(_0x43f7aa(_0x3da58b[_0x44619e(0x172)][_0x2bf2ee][_0x44619e(0x179)])?'\x20'+_0x3da58b['rules'][_0x2bf2ee][_0x44619e(0x142)]:'');}return _0x50b30a+')';};let _0x3c8523={'where':{'id':_0x18862a['params']['id']}},_0x43766a,_0x35b031,_0x3768b2;return _0x3c8523=_['merge']({},_0x3c8523,_0x18862a[_0x373ebf(0x169)]),db[_0x373ebf(0x118)][_0x373ebf(0x115)](_0x3c8523)['then'](function(_0x33158b){const _0x41de2b=_0x373ebf;if(_0x33158b)return _0x43766a=_0x33158b,_0x33158b[_0x41de2b(0x11e)]();return null;})[_0x373ebf(0x167)](function(_0x11dc25){const _0x2dca10=_0x373ebf;if(_0x11dc25){if(!_0x11dc25['length'])throw new ValidationErrorItem(_0x2dca10(0x185),0x193);return _0x35b031=_0x11dc25,db[_0x2dca10(0x17b)][_0x2dca10(0xfc)]({'raw':!![]});}return null;})['then'](function(_0x112758){const _0x22b451=_0x373ebf;if(_0x112758){_0x3768b2=_[_0x22b451(0x184)](_0x112758,'id');let _0x469126;const _0x5554ec=squel[_0x22b451(0x141)]();_0x5554ec[_0x22b451(0x129)](_0x43766a[_0x22b451(0x116)]);for(let _0x34fedb=0x0;_0x34fedb<_0x35b031['length'];_0x34fedb+=0x1){_0x469126=_0x35b031[_0x34fedb][_0x22b451(0xfd)]?_0x3768b2[_0x35b031[_0x34fedb][_0x22b451(0xfd)]][_0x22b451(0x132)]:_0x35b031[_0x34fedb][_0x22b451(0x134)],_0x469126=_0x35b031[_0x34fedb][_0x22b451(0x15d)]?_[_0x22b451(0x103)](_0x205097[_0x35b031[_0x34fedb][_0x22b451(0x15d)]],'%s',_0x469126):_0x469126,_0x469126=_0x35b031[_0x34fedb][_0x22b451(0x130)]?_[_0x22b451(0x103)](_0xd573f3[_0x35b031[_0x34fedb]['format']],'%s',_0x469126):_0x469126,_0x35b031[_0x34fedb][_0x22b451(0x14c)]&&_0x5554ec[_0x22b451(0x159)](_0x469126),_0x35b031[_0x34fedb][_0x22b451(0x166)]&&_0x5554ec['order'](_0x469126,_0x35b031[_0x34fedb][_0x22b451(0x166)]===_0x22b451(0x111)?![]:!![]),_0x5554ec['field'](_0x469126,_0x35b031[_0x34fedb][_0x22b451(0x17d)]||_0x469126);}if(_0x43766a[_0x22b451(0x10a)]){_0x43766a['joins']=JSON[_0x22b451(0x13f)](_0x43766a[_0x22b451(0x10a)]);for(let _0x54ff9e=0x0;_0x54ff9e<_0x43766a[_0x22b451(0x10a)][_0x22b451(0x120)];_0x54ff9e+=0x1){_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x14a)]&&_['includes'](_0xf75c77,_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x14a)])&&_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x113)]&&_0x43766a[_0x22b451(0x10a)][_0x54ff9e]['foreignTable']&&_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x11c)]&&_0x5554ec[_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x14a)]](_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x12b)],null,util['format']('%s.%s\x20=\x20%s.%s',_0x43766a[_0x22b451(0x116)],_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x113)],_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x12b)],_0x43766a[_0x22b451(0x10a)][_0x54ff9e][_0x22b451(0x11c)]));}}return _0x43766a[_0x22b451(0x136)]&&(_0x43766a[_0x22b451(0x136)]=JSON['parse'](_0x43766a[_0x22b451(0x136)]),_0x5554ec[_0x22b451(0x14e)](_0x5ae1ce(_0x43766a['conditions'][_0x22b451(0x159)]))),_0x5554ec['limit'](_0x1d5ed9),_0x5554ec[_0x22b451(0x152)](0x0),logger[_0x22b451(0x161)]('Limited\x20Query:',_0x5554ec[_0x22b451(0x160)]()),db[_0x22b451(0x13c)][_0x22b451(0x106)](_0x5554ec[_0x22b451(0x160)](),{'type':QueryTypes['SELECT']});}})[_0x373ebf(0x167)](respondWithResult(_0x161a14,null))[_0x373ebf(0x13d)](handleError(_0x161a14,null));};function runReport(_0x8498ef,_0x3c8059,_0xea5cdc){const _0x4407be=a11_0x51591f,_0x4e6f91=_0x3c8059['name'],_0x1b7643=0xa,_0xc30adc=[_0x4407be(0x174),_0x4407be(0x150),_0x4407be(0xfa),_0x4407be(0x11a)],_0x30badf={'SUM':_0x4407be(0x15e),'COUNT':_0x4407be(0x183),'COUNT\x20DISTINCT':_0x4407be(0xf9),'MAX':_0x4407be(0x128),'MIN':'MIN(%s)','AVG':_0x4407be(0x10e),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT\x20ASC':_0x4407be(0x151),'GROUP_CONCAT\x20DESC':_0x4407be(0x12d)},_0x91d659={'SEC_TO_TIME':_0x4407be(0x16c),'DATE':_0x4407be(0x156),'HOUR':_0x4407be(0x153),'ROUND':_0x4407be(0x17f),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'},_0x410ca4=function(_0x5c6055){const _0x1cdf56=_0x4407be;return!_[_0x1cdf56(0x11b)]([_0x1cdf56(0x157),_0x1cdf56(0x147),'IS\x20EMPTY',_0x1cdf56(0x110)],_0x5c6055);},_0x392590=function(_0x3cd797){const _0x9af213=_0x4407be;if(!_0x3cd797||!_0x3cd797[_0x9af213(0x172)]['length'])return'';let _0xd360a7='(';for(let _0x1c3e19=0x0;_0x1c3e19<_0x3cd797[_0x9af213(0x172)][_0x9af213(0x120)];_0x1c3e19+=0x1){_0x1c3e19>0x0&&(_0xd360a7+='\x20'+_0x3cd797['operator']+'\x20'),_0xd360a7+=_0x3cd797[_0x9af213(0x172)][_0x1c3e19][_0x9af213(0x159)]?_0x392590(_0x3cd797['rules'][_0x1c3e19][_0x9af213(0x159)]):_0x3cd797[_0x9af213(0x172)][_0x1c3e19][_0x9af213(0x134)]+'\x20'+_0x3cd797[_0x9af213(0x172)][_0x1c3e19][_0x9af213(0x179)]+(_0x410ca4(_0x3cd797[_0x9af213(0x172)][_0x1c3e19][_0x9af213(0x179)])?'\x20'+_0x3cd797[_0x9af213(0x172)][_0x1c3e19][_0x9af213(0x142)]:'');}return _0xd360a7+')';};let _0x259b1a={'where':{'id':_0x8498ef['id']}},_0x395762,_0x4daf6d,_0x4a4d36,_0x3c1650,_0x27d9d5;return _0x259b1a=_[_0x4407be(0x121)]({},_0x259b1a,_0xea5cdc),db['AnalyticDefaultReport']['findOne'](_0x259b1a)[_0x4407be(0x167)](function(_0x25c838){if(_0x25c838)return _0x395762=_0x25c838,_0x25c838['getFields']();return null;})[_0x4407be(0x167)](function(_0x4678b2){const _0x4a8c5e=_0x4407be;if(_0x4678b2){if(!_0x4678b2['length'])throw new ValidationErrorItem(_0x4a8c5e(0x185),0x193);return _0x4daf6d=_0x4678b2,db['AnalyticMetric'][_0x4a8c5e(0xfc)]({'raw':!![]});}return null;})[_0x4407be(0x167)](function(_0x3d09dd){const _0x292dd5=_0x4407be;if(_0x3d09dd){_0x4a4d36=_[_0x292dd5(0x184)](_0x3d09dd,'id');let _0x2d4e22;const _0x2de2cf=squel[_0x292dd5(0x141)]();_0x2de2cf[_0x292dd5(0x129)](_0x395762[_0x292dd5(0x116)]);for(let _0x1f9777=0x0;_0x1f9777<_0x4daf6d[_0x292dd5(0x120)];_0x1f9777+=0x1){_0x2d4e22=_0x4daf6d[_0x1f9777][_0x292dd5(0xfd)]?_0x4a4d36[_0x4daf6d[_0x1f9777]['MetricId']]['metric']:_0x4daf6d[_0x1f9777]['field'],_0x2d4e22=_0x4daf6d[_0x1f9777][_0x292dd5(0x15d)]?_[_0x292dd5(0x103)](_0x30badf[_0x4daf6d[_0x1f9777][_0x292dd5(0x15d)]],'%s',_0x2d4e22):_0x2d4e22,_0x2d4e22=_0x4daf6d[_0x1f9777]['format']?_['replace'](_0x91d659[_0x4daf6d[_0x1f9777][_0x292dd5(0x130)]],'%s',_0x2d4e22):_0x2d4e22,_0x4daf6d[_0x1f9777][_0x292dd5(0x14c)]&&_0x2de2cf[_0x292dd5(0x159)](_0x2d4e22),_0x4daf6d[_0x1f9777][_0x292dd5(0x166)]&&_0x2de2cf['order'](_0x2d4e22,_0x4daf6d[_0x1f9777][_0x292dd5(0x166)]===_0x292dd5(0x111)?![]:!![]),_0x2de2cf['field'](_0x2d4e22,_0x4daf6d[_0x1f9777][_0x292dd5(0x17d)]||_0x2d4e22);}if(_0x395762['joins']){_0x395762['joins']=JSON[_0x292dd5(0x13f)](_0x395762[_0x292dd5(0x10a)]);for(let _0x516acd=0x0;_0x516acd<_0x395762['joins'][_0x292dd5(0x120)];_0x516acd+=0x1){_0x395762['joins'][_0x516acd][_0x292dd5(0x14a)]&&_[_0x292dd5(0x11b)](_0xc30adc,_0x395762[_0x292dd5(0x10a)][_0x516acd]['type'])&&_0x395762[_0x292dd5(0x10a)][_0x516acd]['parentKey']&&_0x395762['joins'][_0x516acd][_0x292dd5(0x12b)]&&_0x395762[_0x292dd5(0x10a)][_0x516acd][_0x292dd5(0x11c)]&&_0x2de2cf[_0x395762['joins'][_0x516acd]['type']](_0x395762[_0x292dd5(0x10a)][_0x516acd][_0x292dd5(0x12b)],null,util[_0x292dd5(0x130)](_0x292dd5(0x13a),_0x395762[_0x292dd5(0x116)],_0x395762[_0x292dd5(0x10a)][_0x516acd][_0x292dd5(0x113)],_0x395762[_0x292dd5(0x10a)][_0x516acd][_0x292dd5(0x12b)],_0x395762['joins'][_0x516acd][_0x292dd5(0x11c)]));}}return _0x395762[_0x292dd5(0x136)]&&(_0x395762[_0x292dd5(0x136)]=JSON[_0x292dd5(0x13f)](_0x395762['conditions']),_0x2de2cf[_0x292dd5(0x14e)](_0x392590(_0x395762['conditions'][_0x292dd5(0x159)]))),_0x27d9d5=_0x2de2cf['clone'](),_0x2de2cf[_0x292dd5(0x13b)](_0x1b7643),_0x2de2cf[_0x292dd5(0x152)](0x0),logger[_0x292dd5(0x161)](_0x292dd5(0x10b),_0x2de2cf[_0x292dd5(0x160)]()),db[_0x292dd5(0x13c)][_0x292dd5(0x106)](_0x2de2cf['toString'](),{'type':QueryTypes[_0x292dd5(0x148)]});}})[_0x4407be(0x167)](function(_0x3c390d){const _0x505b79=_0x4407be;if(!_0x3c390d[_0x505b79(0x120)])throw new ValidationErrorItem(_0x505b79(0x10d),0xcc);if(_0x3c8059['output']==='web')return null;const _0x1738cf=_[_0x505b79(0x121)](_0x3c8059,{'name':_0x3c8059[_0x505b79(0x15a)]||_0x3c8059['name']||_0x395762['name'],'basename':_0x4e6f91,'savename':util[_0x505b79(0x130)](_0x505b79(0x119),_0x3c8059[_0x505b79(0x122)]||_0x395762[_0x505b79(0x122)],require(_0x505b79(0x154))[_0x505b79(0x127)](0x4),_0x3c8059['output']||_0x505b79(0xfb)),'reportId':_0x395762['id'],'reportType':_0x505b79(0x17a)});return db['AnalyticExtractedReport'][_0x505b79(0x133)](_0x1738cf,{'raw':!![]});})[_0x4407be(0x167)](function(_0x4302ce){const _0x4996ad=_0x4407be;_0x395762[_0x4996ad(0x116)]==='cdr'?_0x27d9d5[_0x4996ad(0x14e)](_0x395762[_0x4996ad(0x116)]+'.calldate\x20BETWEEN\x20?\x20AND\x20?',_0x3c8059['startDate'],_0x3c8059[_0x4996ad(0x135)]):_0x27d9d5[_0x4996ad(0x14e)](_0x395762[_0x4996ad(0x116)]+_0x4996ad(0x182),_0x3c8059[_0x4996ad(0x104)],_0x3c8059[_0x4996ad(0x135)]);if(_0x4302ce)return logger['info'](_0x4996ad(0x11f),_0x27d9d5[_0x4996ad(0x160)]()),require(_0x4996ad(0x173))[_0x4996ad(0x16e)](path['join'](__dirname,'../../components/export/',_0x4302ce[_0x4996ad(0x143)]),[_0x4302ce['id'],_0x27d9d5[_0x4996ad(0x160)](),path['join'](__dirname,_0x4996ad(0x17c),_0x4302ce[_0x4996ad(0x15b)]),_0x4e6f91]),_0x4302ce;else{const _0x400f47=squel['select']();return _0x400f47[_0x4996ad(0x129)]('('+_0x27d9d5[_0x4996ad(0x160)]()+')',_0x4996ad(0x15c)),_0x400f47[_0x4996ad(0x134)](_0x4996ad(0x158),'count'),_0x27d9d5['limit'](_0x3c8059[_0x4996ad(0x13b)]||_0x1b7643),_0x27d9d5[_0x4996ad(0x152)](_0x3c8059[_0x4996ad(0x152)]||0x0),dbH[_0x4996ad(0x13c)][_0x4996ad(0x106)](_0x400f47[_0x4996ad(0x160)](),{'type':dbH[_0x4996ad(0x13c)][_0x4996ad(0x140)][_0x4996ad(0x148)]})[_0x4996ad(0x167)](function(_0x2cee10){const _0xde7c94=_0x4996ad;return!_0x2cee10[_0xde7c94(0x120)]?_0x3c1650=0x0:_0x3c1650=_0x2cee10[0x0][_0xde7c94(0x155)]||0x0,dbH['sequelize']['query'](_0x27d9d5['toString'](),{'type':dbH[_0xde7c94(0x13c)][_0xde7c94(0x140)]['SELECT']});})[_0x4996ad(0x167)](function(_0x20c93c){return{'rows':_0x20c93c||[],'count':_0x3c1650};});}});}exports['run']=function(_0x161091,_0x18ba19){const _0x1e2c26=a11_0x51591f;return runReport(_0x161091['params'],_0x161091['query'],_0x161091[_0x1e2c26(0x169)])[_0x1e2c26(0x167)](respondWithResult(_0x18ba19,null))['catch'](handleError(_0x18ba19,null));},exports['runReport']=runReport,exports[a11_0x51591f(0x106)]=function(_0x52c79f,_0x56639c){const _0x1f9e5d=a11_0x51591f,_0x299ec1=0xa,_0x4327d7=['join','left_join','right_join',_0x1f9e5d(0x11a)],_0x52449c={'SUM':_0x1f9e5d(0x15e),'COUNT':_0x1f9e5d(0x183),'COUNT\x20DISTINCT':_0x1f9e5d(0xf9),'MAX':_0x1f9e5d(0x128),'MIN':_0x1f9e5d(0x126),'AVG':_0x1f9e5d(0x10e),'GROUP_CONCAT':'GROUP_CONCAT(%s)','GROUP_CONCAT\x20ASC':_0x1f9e5d(0x151),'GROUP_CONCAT\x20DESC':_0x1f9e5d(0x12d)},_0x58f756={'SEC_TO_TIME':_0x1f9e5d(0x16c),'DATE':_0x1f9e5d(0x156),'HOUR':_0x1f9e5d(0x153),'ROUND':'ROUND(%s)','UNIX_TIMESTAMP':_0x1f9e5d(0x13e)},_0x9791ec=function(_0xdf8d35){const _0x46e1e0=_0x1f9e5d;return!_[_0x46e1e0(0x11b)](['IS\x20NULL',_0x46e1e0(0x147),_0x46e1e0(0x124),_0x46e1e0(0x110)],_0xdf8d35);},_0x499754=function(_0x55c058){const _0x3b4772=_0x1f9e5d;if(!_0x55c058||!_0x55c058[_0x3b4772(0x172)][_0x3b4772(0x120)])return'';let _0x292b50='(';for(let _0x280e60=0x0;_0x280e60<_0x55c058['rules']['length'];_0x280e60+=0x1){_0x280e60>0x0&&(_0x292b50+='\x20'+_0x55c058[_0x3b4772(0x16f)]+'\x20'),_0x292b50+=_0x55c058[_0x3b4772(0x172)][_0x280e60][_0x3b4772(0x159)]?_0x499754(_0x55c058[_0x3b4772(0x172)][_0x280e60]['group']):_0x55c058[_0x3b4772(0x172)][_0x280e60][_0x3b4772(0x134)]+'\x20'+_0x55c058[_0x3b4772(0x172)][_0x280e60][_0x3b4772(0x179)]+(_0x9791ec(_0x55c058[_0x3b4772(0x172)][_0x280e60]['condition'])?'\x20'+_0x55c058[_0x3b4772(0x172)][_0x280e60][_0x3b4772(0x142)]:'');}return _0x292b50+')';};let _0x4ac6d3={'where':{'id':_0x52c79f[_0x1f9e5d(0x146)]['id']}},_0x33531c,_0x2b6a19,_0x57d45b,_0x14e30a;return _0x4ac6d3=_['merge']({},_0x4ac6d3,_0x52c79f[_0x1f9e5d(0x169)]),db['AnalyticDefaultReport'][_0x1f9e5d(0x115)](_0x4ac6d3)[_0x1f9e5d(0x167)](function(_0x458a74){const _0x1a9067=_0x1f9e5d;if(_0x458a74)return _0x33531c=_0x458a74,_0x458a74[_0x1a9067(0x11e)]();return null;})[_0x1f9e5d(0x167)](function(_0x3b08f4){const _0x1a24bd=_0x1f9e5d;if(_0x3b08f4){if(!_0x3b08f4[_0x1a24bd(0x120)])throw new ValidationErrorItem(_0x1a24bd(0x185),0x193);return _0x2b6a19=_0x3b08f4,db[_0x1a24bd(0x17b)][_0x1a24bd(0xfc)]({'raw':!![]});}return null;})['then'](function(_0x82fc30){const _0x2499c=_0x1f9e5d;if(_0x82fc30){_0x57d45b=_[_0x2499c(0x184)](_0x82fc30,'id');let _0x391a7a;const _0x4b9393=squel[_0x2499c(0x141)]();_0x4b9393[_0x2499c(0x129)](_0x33531c[_0x2499c(0x116)]);for(let _0xba97f7=0x0;_0xba97f7<_0x2b6a19[_0x2499c(0x120)];_0xba97f7+=0x1){_0x391a7a=_0x2b6a19[_0xba97f7][_0x2499c(0xfd)]?_0x57d45b[_0x2b6a19[_0xba97f7][_0x2499c(0xfd)]][_0x2499c(0x132)]:_0x2b6a19[_0xba97f7][_0x2499c(0x134)],_0x391a7a=_0x2b6a19[_0xba97f7][_0x2499c(0x15d)]?_['replace'](_0x52449c[_0x2b6a19[_0xba97f7][_0x2499c(0x15d)]],'%s',_0x391a7a):_0x391a7a,_0x391a7a=_0x2b6a19[_0xba97f7][_0x2499c(0x130)]?_['replace'](_0x58f756[_0x2b6a19[_0xba97f7]['format']],'%s',_0x391a7a):_0x391a7a,_0x2b6a19[_0xba97f7]['groupBy']&&_0x4b9393['group'](_0x391a7a),_0x2b6a19[_0xba97f7][_0x2499c(0x166)]&&_0x4b9393[_0x2499c(0x102)](_0x391a7a,_0x2b6a19[_0xba97f7]['orderBy']===_0x2499c(0x111)?![]:!![]),_0x4b9393[_0x2499c(0x134)](_0x391a7a,_0x2b6a19[_0xba97f7][_0x2499c(0x17d)]||_0x391a7a);}if(_0x33531c[_0x2499c(0x10a)]){_0x33531c[_0x2499c(0x10a)]=JSON[_0x2499c(0x13f)](_0x33531c[_0x2499c(0x10a)]);for(let _0x5f0b39=0x0;_0x5f0b39<_0x33531c[_0x2499c(0x10a)][_0x2499c(0x120)];_0x5f0b39+=0x1){_0x33531c['joins'][_0x5f0b39][_0x2499c(0x14a)]&&_[_0x2499c(0x11b)](_0x4327d7,_0x33531c['joins'][_0x5f0b39]['type'])&&_0x33531c['joins'][_0x5f0b39][_0x2499c(0x113)]&&_0x33531c[_0x2499c(0x10a)][_0x5f0b39][_0x2499c(0x12b)]&&_0x33531c['joins'][_0x5f0b39][_0x2499c(0x11c)]&&_0x4b9393[_0x33531c[_0x2499c(0x10a)][_0x5f0b39]['type']](_0x33531c[_0x2499c(0x10a)][_0x5f0b39][_0x2499c(0x12b)],null,util[_0x2499c(0x130)](_0x2499c(0x13a),_0x33531c[_0x2499c(0x116)],_0x33531c[_0x2499c(0x10a)][_0x5f0b39][_0x2499c(0x113)],_0x33531c['joins'][_0x5f0b39]['foreignTable'],_0x33531c[_0x2499c(0x10a)][_0x5f0b39][_0x2499c(0x11c)]));}}return _0x33531c[_0x2499c(0x136)]&&(_0x33531c['conditions']=JSON['parse'](_0x33531c[_0x2499c(0x136)]),_0x4b9393[_0x2499c(0x14e)](_0x499754(_0x33531c[_0x2499c(0x136)][_0x2499c(0x159)]))),_0x14e30a=_0x4b9393['clone'](),_0x4b9393[_0x2499c(0x13b)](_0x299ec1),_0x4b9393['offset'](0x0),logger[_0x2499c(0x161)](_0x2499c(0x10b),_0x4b9393[_0x2499c(0x160)]()),db['sequelize']['query'](_0x4b9393[_0x2499c(0x160)](),{'type':QueryTypes['SELECT']});}})['then'](function(){const _0x1a34eb=_0x1f9e5d;return{'sql':_0x14e30a[_0x1a34eb(0x160)]()};})['then'](respondWithResult(_0x56639c,null))['catch'](handleError(_0x56639c,null));};
\ No newline at end of file
+const a11_0x83bb=['foreignKey','end','attributes','QueryTypes','right_join','VIRTUAL','Please\x20insert\x20at\x20least\x20one\x20field','then','merge','csv','AVG(%s)','rules','include','index','SUM(%s)','set','includes','includeAll','MAX(%s)','filters','Limited\x20Query:','join','endDate','model','%s.%s\x20=\x20%s.%s','Content-Range','UNIX_TIMESTAMP(%s)','parentKey','IS\x20NULL','user','savename','order','preview','Run\x20Query:','filter','json','UserProfileResource','HOUR(%s)','COUNT(DISTINCT\x20%s)','orderBy','../../mysqldb','cross_join','output','findOne','update','AnalyticDefaultReport','MetricId','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','sendStatus','condition','countTable','destroy','ROUND(%s)','fields','AnalyticExtractedReport','api','value','select','fork','offset','userProfileId','.createdAt\x20BETWEEN\x20?\x20AND\x20?','SEC_TO_TIME(%s)','run','AnalyticMetric','alias','create','runReport','conditions','IS\x20EMPTY','name','lodash','pick','cdr','DATE(%s)','field','sequelize','table','get','metric','format','error','groupBy','status','from','foreignTable','query','parse','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','getFields','limit','replace','fieldName','debug','like','path','type','keys','catch','rawAttributes','MIN(%s)','map','sort','SELECT','operator','key','Reports','GROUP_CONCAT(%s)','Unable\x20to\x20retrieve\x20the\x20current\x20user','clone','GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20DESC)','web','rows','startDate','COUNT(%s)','group','DefaultReports','options','UserProfileSection','where','intersection','joins','IS\x20NOT\x20EMPTY','params','%s-%s.%s','fullPath','../../components/parsers/qs','keyBy','send','count','DESC','findAll','left_join','.calldate\x20BETWEEN\x20?\x20AND\x20?','autoAssociation','function','body','IS\x20NOT\x20NULL','show','squel','role','toString','length'];(function(_0x1b97bf,_0x5a2aed){const _0x83bb87=function(_0x14051e){while(--_0x14051e){_0x1b97bf['push'](_0x1b97bf['shift']());}};_0x83bb87(++_0x5a2aed);}(a11_0x83bb,0xbe));const a11_0x1405=function(_0x1b97bf,_0x5a2aed){_0x1b97bf=_0x1b97bf-0x106;let _0x83bb87=a11_0x83bb[_0x1b97bf];return _0x83bb87;};const a11_0xc5652e=a11_0x1405;'use strict';const util=require('util'),path=require(a11_0xc5652e(0x136)),_=require(a11_0xc5652e(0x11e)),squel=require(a11_0xc5652e(0x162)),qs=require(a11_0xc5652e(0x155)),logger=require('../../config/logger')(a11_0xc5652e(0x10e)),{db}=require('../../mysqldb'),dbH=require(a11_0xc5652e(0x18e))['dbH'],{Op,ValidationErrorItem,QueryTypes}=require(a11_0xc5652e(0x123));function respondWithResult(_0x3d4779,_0x44117d){return _0x44117d=_0x44117d||0xc8,function(_0x458dce){const _0x5b6c30=a11_0x1405;if(_0x458dce)return _0x3d4779['status'](_0x44117d)[_0x5b6c30(0x189)](_0x458dce);};}function respondWithFilteredResult(_0x8e28fa,_0x3f52f1){return function(_0x1c983a){const _0x2b02e7=a11_0x1405;if(_0x1c983a){const _0x4301d5=_0x1c983a[_0x2b02e7(0x158)],_0x9610f=_0x3f52f1['offset'];let _0xad5b1f=_0x3f52f1['offset']+_0x3f52f1[_0x2b02e7(0x131)],_0x2a8cc3;return _0xad5b1f>=_0x4301d5?(_0xad5b1f=_0x4301d5,_0x2a8cc3=0xc8):_0x2a8cc3=0xce,_0x8e28fa[_0x2b02e7(0x12a)](_0x2a8cc3),_0x8e28fa[_0x2b02e7(0x175)](_0x2b02e7(0x17f),_0x9610f+'-'+_0xad5b1f+'/'+_0x4301d5)[_0x2b02e7(0x189)](_0x1c983a);}return null;};}function saveUpdates(_0x4ae62e){return function(_0x22b198){const _0x355326=a11_0x1405;if(_0x22b198)return _0x22b198['update'](_0x4ae62e)[_0x355326(0x16d)](function(_0x53bd38){return _0x53bd38;});return null;};}function removeEntity(_0x21d9cd){return function(_0x3cb256){const _0x4f0d7f=a11_0x1405;if(_0x3cb256)return _0x3cb256[_0x4f0d7f(0x10a)]()[_0x4f0d7f(0x16d)](function(){const _0x390290=_0x4f0d7f,_0x1f2d34=_0x3cb256['get']({'plain':!![]}),_0x5b44e4=_0x390290(0x14b);return db[_0x390290(0x18a)][_0x390290(0x10a)]({'where':{'type':_0x5b44e4,'resourceId':_0x1f2d34['id']}})[_0x390290(0x16d)](function(){return _0x3cb256;});})[_0x4f0d7f(0x16d)](function(){const _0x58c87b=_0x4f0d7f;_0x21d9cd['status'](0xcc)[_0x58c87b(0x167)]();});};}function handleEntityNotFound(_0x2083a9){return function(_0x1b5f2f){const _0x32fee6=a11_0x1405;return!_0x1b5f2f&&_0x2083a9[_0x32fee6(0x107)](0x194),_0x1b5f2f;};}function handleError(_0x28cde2,_0x558cea){return _0x558cea=_0x558cea||0x1f4,function(_0x15362b){const _0x9342e9=a11_0x1405;logger['error'](_0x15362b['stack']),_0x15362b[_0x9342e9(0x11d)]&&delete _0x15362b[_0x9342e9(0x11d)],_0x28cde2[_0x9342e9(0x12a)](_0x558cea)[_0x9342e9(0x157)](_0x15362b);};}exports[a11_0xc5652e(0x173)]=function(_0x21891c,_0x55b057){const _0x2c42a0=a11_0xc5652e;let _0xbfe2f9={};const _0x2bf584={},_0x3527a6={'count':0x0,'rows':[]},_0x79251a=_[_0x2c42a0(0x13c)](db[_0x2c42a0(0x193)][_0x2c42a0(0x13a)],function(_0x502068){const _0x17c943=_0x2c42a0;return{'name':_0x502068[_0x17c943(0x133)],'type':_0x502068[_0x17c943(0x137)][_0x17c943(0x140)]};});_0x2bf584[_0x2c42a0(0x17d)]=_[_0x2c42a0(0x13c)](_0x79251a,_0x2c42a0(0x11d)),_0x2bf584[_0x2c42a0(0x12d)]=_[_0x2c42a0(0x138)](_0x21891c[_0x2c42a0(0x12d)]),_0x2bf584[_0x2c42a0(0x179)]=_[_0x2c42a0(0x14f)](_0x2bf584[_0x2c42a0(0x17d)],_0x2bf584[_0x2c42a0(0x12d)]),_0xbfe2f9[_0x2c42a0(0x168)]=_['intersection'](_0x2bf584[_0x2c42a0(0x17d)],qs[_0x2c42a0(0x10c)](_0x21891c[_0x2c42a0(0x12d)]['fields'])),_0xbfe2f9[_0x2c42a0(0x168)]=_0xbfe2f9['attributes'][_0x2c42a0(0x165)]?_0xbfe2f9[_0x2c42a0(0x168)]:_0x2bf584[_0x2c42a0(0x17d)];typeof _0x21891c[_0x2c42a0(0x12d)]['nolimit']==='undefined'&&(_0xbfe2f9['limit']=qs[_0x2c42a0(0x131)](_0x21891c[_0x2c42a0(0x12d)][_0x2c42a0(0x131)]),_0xbfe2f9['offset']=qs['offset'](_0x21891c[_0x2c42a0(0x12d)][_0x2c42a0(0x112)]));_0xbfe2f9['order']=qs['sort'](_0x21891c[_0x2c42a0(0x12d)][_0x2c42a0(0x13d)]),_0xbfe2f9[_0x2c42a0(0x14e)]=qs[_0x2c42a0(0x179)](_[_0x2c42a0(0x11f)](_0x21891c[_0x2c42a0(0x12d)],_0x2bf584[_0x2c42a0(0x179)]),_0x79251a);_0x21891c[_0x2c42a0(0x12d)][_0x2c42a0(0x188)]&&(_0xbfe2f9['where']=_['merge'](_0xbfe2f9[_0x2c42a0(0x14e)],{[Op['or']]:_[_0x2c42a0(0x13c)](_0x79251a,function(_0x53e87b){const _0x24ed5a=_0x2c42a0;if(_0x53e87b[_0x24ed5a(0x137)]!==_0x24ed5a(0x16b)){const _0x2f52e4={};return _0x2f52e4[_0x53e87b[_0x24ed5a(0x11d)]]={[Op[_0x24ed5a(0x135)]]:'%'+_0x21891c[_0x24ed5a(0x12d)][_0x24ed5a(0x188)]+'%'},_0x2f52e4;}})}));_0xbfe2f9=_[_0x2c42a0(0x16e)]({},_0xbfe2f9,_0x21891c[_0x2c42a0(0x14c)]);const _0x39c7bd={'where':_0xbfe2f9[_0x2c42a0(0x14e)]};return db['AnalyticDefaultReport']['count'](_0x39c7bd)[_0x2c42a0(0x16d)](function(_0x155ec0){const _0x26be70=_0x2c42a0;return _0x3527a6[_0x26be70(0x158)]=_0x155ec0,_0x21891c[_0x26be70(0x12d)][_0x26be70(0x177)]&&(_0xbfe2f9[_0x26be70(0x172)]=[{'all':!![]}]),db[_0x26be70(0x193)]['findAll'](_0xbfe2f9);})[_0x2c42a0(0x16d)](function(_0x2cf261){const _0x51931b=_0x2c42a0;return _0x3527a6[_0x51931b(0x147)]=_0x2cf261,_0x3527a6;})[_0x2c42a0(0x16d)](respondWithFilteredResult(_0x55b057,_0xbfe2f9))[_0x2c42a0(0x139)](handleError(_0x55b057,null));},exports[a11_0xc5652e(0x161)]=function(_0x4a2e27,_0x35f3a9){const _0x2a1413=a11_0xc5652e;let _0x2198cc={'raw':!![],'where':{'id':_0x4a2e27[_0x2a1413(0x152)]['id']}};const _0xc0a96f={};return _0xc0a96f[_0x2a1413(0x17d)]=_[_0x2a1413(0x138)](db[_0x2a1413(0x193)]['rawAttributes']),_0xc0a96f[_0x2a1413(0x12d)]=_[_0x2a1413(0x138)](_0x4a2e27[_0x2a1413(0x12d)]),_0xc0a96f[_0x2a1413(0x179)]=_['intersection'](_0xc0a96f[_0x2a1413(0x17d)],_0xc0a96f['query']),_0x2198cc[_0x2a1413(0x168)]=_[_0x2a1413(0x14f)](_0xc0a96f['model'],qs['fields'](_0x4a2e27[_0x2a1413(0x12d)][_0x2a1413(0x10c)])),_0x2198cc[_0x2a1413(0x168)]=_0x2198cc[_0x2a1413(0x168)][_0x2a1413(0x165)]?_0x2198cc['attributes']:_0xc0a96f[_0x2a1413(0x17d)],_0x4a2e27[_0x2a1413(0x12d)]['includeAll']&&(_0x2198cc[_0x2a1413(0x172)]=[{'all':!![]}]),_0x2198cc=_[_0x2a1413(0x16e)]({},_0x2198cc,_0x4a2e27[_0x2a1413(0x14c)]),db[_0x2a1413(0x193)][_0x2a1413(0x191)](_0x2198cc)[_0x2a1413(0x16d)](handleEntityNotFound(_0x35f3a9,null))[_0x2a1413(0x16d)](respondWithResult(_0x35f3a9,null))[_0x2a1413(0x139)](handleError(_0x35f3a9,null));},exports[a11_0xc5652e(0x119)]=function(_0x48fff9,_0x265683){const _0x192ac4=a11_0xc5652e;return db[_0x192ac4(0x193)][_0x192ac4(0x119)](_0x48fff9[_0x192ac4(0x15f)],{})[_0x192ac4(0x16d)](function(_0x1a7f1b){const _0x3d9d65=_0x192ac4,_0x4c6638=_0x48fff9[_0x3d9d65(0x183)][_0x3d9d65(0x125)]({'plain':!![]});if(!_0x4c6638)throw new Error(_0x3d9d65(0x143));if(_0x4c6638[_0x3d9d65(0x163)]==='user'){const _0x2b7901=_0x1a7f1b[_0x3d9d65(0x125)]({'plain':!![]}),_0x2fd5ea=_0x3d9d65(0x141);return db[_0x3d9d65(0x14d)][_0x3d9d65(0x191)]({'where':{'name':_0x2fd5ea,'userProfileId':_0x4c6638[_0x3d9d65(0x113)]},'raw':!![]})[_0x3d9d65(0x16d)](function(_0x496598){const _0x28abf0=_0x3d9d65;return _0x496598&&_0x496598[_0x28abf0(0x15d)]===0x0?db[_0x28abf0(0x18a)][_0x28abf0(0x119)]({'name':_0x2b7901[_0x28abf0(0x11d)],'resourceId':_0x2b7901['id'],'type':_0x28abf0(0x14b),'sectionId':_0x496598['id']},{})[_0x28abf0(0x16d)](function(){return _0x1a7f1b;}):_0x1a7f1b;})[_0x3d9d65(0x139)](function(_0x473cf7){const _0x140287=_0x3d9d65;logger[_0x140287(0x128)](_0x140287(0x12f),_0x473cf7);throw _0x473cf7;});}return _0x1a7f1b;})[_0x192ac4(0x16d)](respondWithResult(_0x265683,0xc9))[_0x192ac4(0x139)](handleError(_0x265683,null));},exports[a11_0xc5652e(0x192)]=function(_0x48086d,_0x15632e){const _0x485ae2=a11_0xc5652e;return _0x48086d[_0x485ae2(0x15f)]['id']&&delete _0x48086d['body']['id'],db[_0x485ae2(0x193)][_0x485ae2(0x191)]({'where':{'id':_0x48086d['params']['id']}})[_0x485ae2(0x16d)](handleEntityNotFound(_0x15632e,null))[_0x485ae2(0x16d)](saveUpdates(_0x48086d[_0x485ae2(0x15f)],null))[_0x485ae2(0x16d)](respondWithResult(_0x15632e,null))[_0x485ae2(0x139)](handleError(_0x15632e,null));},exports[a11_0xc5652e(0x10a)]=function(_0x580263,_0x2dcc85){const _0x3a3a28=a11_0xc5652e;return db['AnalyticDefaultReport'][_0x3a3a28(0x191)]({'where':{'id':_0x580263['params']['id']}})[_0x3a3a28(0x16d)](handleEntityNotFound(_0x2dcc85,null))['then'](removeEntity(_0x2dcc85,null))['catch'](handleError(_0x2dcc85,null));},exports[a11_0xc5652e(0x186)]=function(_0x2564c3,_0x107ad7){const _0x3fd8f9=a11_0xc5652e,_0x48138e=0xa,_0x39aecd=[_0x3fd8f9(0x17b),_0x3fd8f9(0x15b),_0x3fd8f9(0x16a),'cross_join'],_0xa85290={'SUM':_0x3fd8f9(0x174),'COUNT':_0x3fd8f9(0x149),'COUNT\x20DISTINCT':_0x3fd8f9(0x18c),'MAX':_0x3fd8f9(0x178),'MIN':_0x3fd8f9(0x13b),'AVG':_0x3fd8f9(0x170),'GROUP_CONCAT':_0x3fd8f9(0x142),'GROUP_CONCAT\x20ASC':_0x3fd8f9(0x106),'GROUP_CONCAT\x20DESC':_0x3fd8f9(0x145)},_0x18afc1={'SEC_TO_TIME':_0x3fd8f9(0x115),'DATE':_0x3fd8f9(0x121),'HOUR':'HOUR(%s)','ROUND':_0x3fd8f9(0x10b),'UNIX_TIMESTAMP':_0x3fd8f9(0x180)},_0x3c2084=function(_0x4ef769){const _0x3a5925=_0x3fd8f9;return!_[_0x3a5925(0x176)]([_0x3a5925(0x182),_0x3a5925(0x160),_0x3a5925(0x11c),_0x3a5925(0x151)],_0x4ef769);},_0x73fe1c=function(_0x388540){const _0x2eccb3=_0x3fd8f9;if(!_0x388540||!_0x388540[_0x2eccb3(0x171)]['length'])return'';let _0x130541='(';for(let _0x43b52d=0x0;_0x43b52d<_0x388540[_0x2eccb3(0x171)][_0x2eccb3(0x165)];_0x43b52d+=0x1){_0x43b52d>0x0&&(_0x130541+='\x20'+_0x388540[_0x2eccb3(0x13f)]+'\x20'),_0x130541+=_0x388540[_0x2eccb3(0x171)][_0x43b52d][_0x2eccb3(0x14a)]?_0x73fe1c(_0x388540[_0x2eccb3(0x171)][_0x43b52d][_0x2eccb3(0x14a)]):_0x388540[_0x2eccb3(0x171)][_0x43b52d]['field']+'\x20'+_0x388540[_0x2eccb3(0x171)][_0x43b52d][_0x2eccb3(0x108)]+(_0x3c2084(_0x388540[_0x2eccb3(0x171)][_0x43b52d][_0x2eccb3(0x108)])?'\x20'+_0x388540['rules'][_0x43b52d][_0x2eccb3(0x10f)]:'');}return _0x130541+')';};let _0x561c51={'where':{'id':_0x2564c3[_0x3fd8f9(0x152)]['id']}},_0x2e74b5,_0x1d92e2,_0x1e99a5;return _0x561c51=_[_0x3fd8f9(0x16e)]({},_0x561c51,_0x2564c3[_0x3fd8f9(0x14c)]),db[_0x3fd8f9(0x193)][_0x3fd8f9(0x191)](_0x561c51)[_0x3fd8f9(0x16d)](function(_0x2f54fa){const _0x1c25c1=_0x3fd8f9;if(_0x2f54fa)return _0x2e74b5=_0x2f54fa,_0x2f54fa[_0x1c25c1(0x130)]();return null;})[_0x3fd8f9(0x16d)](function(_0x308687){const _0x2db51e=_0x3fd8f9;if(_0x308687){if(!_0x308687[_0x2db51e(0x165)])throw new ValidationErrorItem('Please\x20insert\x20at\x20least\x20one\x20field',0x193);return _0x1d92e2=_0x308687,db[_0x2db51e(0x117)][_0x2db51e(0x15a)]({'raw':!![]});}return null;})['then'](function(_0x11f7b9){const _0x2710d4=_0x3fd8f9;if(_0x11f7b9){_0x1e99a5=_[_0x2710d4(0x156)](_0x11f7b9,'id');let _0x1f8943;const _0x4352f7=squel[_0x2710d4(0x110)]();_0x4352f7['from'](_0x2e74b5['table']);for(let _0x2ffe4a=0x0;_0x2ffe4a<_0x1d92e2['length'];_0x2ffe4a+=0x1){_0x1f8943=_0x1d92e2[_0x2ffe4a]['MetricId']?_0x1e99a5[_0x1d92e2[_0x2ffe4a]['MetricId']]['metric']:_0x1d92e2[_0x2ffe4a][_0x2710d4(0x122)],_0x1f8943=_0x1d92e2[_0x2ffe4a][_0x2710d4(0x15e)]?_[_0x2710d4(0x132)](_0xa85290[_0x1d92e2[_0x2ffe4a][_0x2710d4(0x15e)]],'%s',_0x1f8943):_0x1f8943,_0x1f8943=_0x1d92e2[_0x2ffe4a][_0x2710d4(0x127)]?_[_0x2710d4(0x132)](_0x18afc1[_0x1d92e2[_0x2ffe4a][_0x2710d4(0x127)]],'%s',_0x1f8943):_0x1f8943,_0x1d92e2[_0x2ffe4a][_0x2710d4(0x129)]&&_0x4352f7[_0x2710d4(0x14a)](_0x1f8943),_0x1d92e2[_0x2ffe4a][_0x2710d4(0x18d)]&&_0x4352f7[_0x2710d4(0x185)](_0x1f8943,_0x1d92e2[_0x2ffe4a][_0x2710d4(0x18d)]==='DESC'?![]:!![]),_0x4352f7[_0x2710d4(0x122)](_0x1f8943,_0x1d92e2[_0x2ffe4a][_0x2710d4(0x118)]||_0x1f8943);}if(_0x2e74b5[_0x2710d4(0x150)]){_0x2e74b5[_0x2710d4(0x150)]=JSON[_0x2710d4(0x12e)](_0x2e74b5[_0x2710d4(0x150)]);for(let _0x2080b2=0x0;_0x2080b2<_0x2e74b5[_0x2710d4(0x150)][_0x2710d4(0x165)];_0x2080b2+=0x1){_0x2e74b5[_0x2710d4(0x150)][_0x2080b2][_0x2710d4(0x137)]&&_['includes'](_0x39aecd,_0x2e74b5[_0x2710d4(0x150)][_0x2080b2][_0x2710d4(0x137)])&&_0x2e74b5[_0x2710d4(0x150)][_0x2080b2][_0x2710d4(0x181)]&&_0x2e74b5[_0x2710d4(0x150)][_0x2080b2][_0x2710d4(0x12c)]&&_0x2e74b5[_0x2710d4(0x150)][_0x2080b2][_0x2710d4(0x166)]&&_0x4352f7[_0x2e74b5['joins'][_0x2080b2][_0x2710d4(0x137)]](_0x2e74b5[_0x2710d4(0x150)][_0x2080b2][_0x2710d4(0x12c)],null,util[_0x2710d4(0x127)]('%s.%s\x20=\x20%s.%s',_0x2e74b5[_0x2710d4(0x124)],_0x2e74b5[_0x2710d4(0x150)][_0x2080b2][_0x2710d4(0x181)],_0x2e74b5[_0x2710d4(0x150)][_0x2080b2]['foreignTable'],_0x2e74b5[_0x2710d4(0x150)][_0x2080b2][_0x2710d4(0x166)]));}}return _0x2e74b5[_0x2710d4(0x11b)]&&(_0x2e74b5[_0x2710d4(0x11b)]=JSON['parse'](_0x2e74b5['conditions']),_0x4352f7[_0x2710d4(0x14e)](_0x73fe1c(_0x2e74b5[_0x2710d4(0x11b)][_0x2710d4(0x14a)]))),_0x4352f7[_0x2710d4(0x131)](_0x48138e),_0x4352f7[_0x2710d4(0x112)](0x0),logger[_0x2710d4(0x134)](_0x2710d4(0x17a),_0x4352f7[_0x2710d4(0x164)]()),db['sequelize'][_0x2710d4(0x12d)](_0x4352f7[_0x2710d4(0x164)](),{'type':QueryTypes['SELECT']});}})['then'](respondWithResult(_0x107ad7,null))[_0x3fd8f9(0x139)](handleError(_0x107ad7,null));};function runReport(_0x133b4e,_0xfe3c45,_0x27d5f9){const _0xc6b206=a11_0xc5652e,_0x50b107=_0xfe3c45[_0xc6b206(0x11d)],_0x128b6d=0xa,_0x4caa65=[_0xc6b206(0x17b),_0xc6b206(0x15b),_0xc6b206(0x16a),_0xc6b206(0x18f)],_0x2b44ad={'SUM':_0xc6b206(0x174),'COUNT':_0xc6b206(0x149),'COUNT\x20DISTINCT':_0xc6b206(0x18c),'MAX':_0xc6b206(0x178),'MIN':'MIN(%s)','AVG':_0xc6b206(0x170),'GROUP_CONCAT':_0xc6b206(0x142),'GROUP_CONCAT\x20ASC':'GROUP_CONCAT(%s\x20ORDER\x20BY\x20%s\x20ASC)','GROUP_CONCAT\x20DESC':_0xc6b206(0x145)},_0x4678d1={'SEC_TO_TIME':_0xc6b206(0x115),'DATE':_0xc6b206(0x121),'HOUR':_0xc6b206(0x18b),'ROUND':_0xc6b206(0x10b),'UNIX_TIMESTAMP':_0xc6b206(0x180)},_0xfa277b=function(_0x37efb1){const _0x426116=_0xc6b206;return!_['includes']([_0x426116(0x182),_0x426116(0x160),_0x426116(0x11c),_0x426116(0x151)],_0x37efb1);},_0x2b7368=function(_0x221171){const _0x70182c=_0xc6b206;if(!_0x221171||!_0x221171['rules'][_0x70182c(0x165)])return'';let _0x2d62f6='(';for(let _0x2ad3d5=0x0;_0x2ad3d5<_0x221171[_0x70182c(0x171)][_0x70182c(0x165)];_0x2ad3d5+=0x1){_0x2ad3d5>0x0&&(_0x2d62f6+='\x20'+_0x221171[_0x70182c(0x13f)]+'\x20'),_0x2d62f6+=_0x221171[_0x70182c(0x171)][_0x2ad3d5][_0x70182c(0x14a)]?_0x2b7368(_0x221171[_0x70182c(0x171)][_0x2ad3d5][_0x70182c(0x14a)]):_0x221171[_0x70182c(0x171)][_0x2ad3d5][_0x70182c(0x122)]+'\x20'+_0x221171['rules'][_0x2ad3d5][_0x70182c(0x108)]+(_0xfa277b(_0x221171[_0x70182c(0x171)][_0x2ad3d5][_0x70182c(0x108)])?'\x20'+_0x221171['rules'][_0x2ad3d5][_0x70182c(0x10f)]:'');}return _0x2d62f6+')';};let _0x5dbdcf={'where':{'id':_0x133b4e['id']}},_0x267d5d,_0x17b6e1,_0x2dee8f,_0x2b4466,_0x23a36d;return _0x5dbdcf=_[_0xc6b206(0x16e)]({},_0x5dbdcf,_0x27d5f9),db[_0xc6b206(0x193)][_0xc6b206(0x191)](_0x5dbdcf)[_0xc6b206(0x16d)](function(_0x26b5fb){const _0xd69529=_0xc6b206;if(_0x26b5fb)return _0x267d5d=_0x26b5fb,_0x26b5fb[_0xd69529(0x130)]();return null;})[_0xc6b206(0x16d)](function(_0x307155){const _0x5cfcba=_0xc6b206;if(_0x307155){if(!_0x307155[_0x5cfcba(0x165)])throw new ValidationErrorItem('Please\x20insert\x20at\x20least\x20one\x20field',0x193);return _0x17b6e1=_0x307155,db['AnalyticMetric'][_0x5cfcba(0x15a)]({'raw':!![]});}return null;})[_0xc6b206(0x16d)](function(_0x12f441){const _0x44c58e=_0xc6b206;if(_0x12f441){_0x2dee8f=_[_0x44c58e(0x156)](_0x12f441,'id');let _0x1818eb;const _0x253be7=squel[_0x44c58e(0x110)]();_0x253be7[_0x44c58e(0x12b)](_0x267d5d[_0x44c58e(0x124)]);for(let _0x10e183=0x0;_0x10e183<_0x17b6e1[_0x44c58e(0x165)];_0x10e183+=0x1){_0x1818eb=_0x17b6e1[_0x10e183][_0x44c58e(0x194)]?_0x2dee8f[_0x17b6e1[_0x10e183][_0x44c58e(0x194)]][_0x44c58e(0x126)]:_0x17b6e1[_0x10e183]['field'],_0x1818eb=_0x17b6e1[_0x10e183][_0x44c58e(0x15e)]?_[_0x44c58e(0x132)](_0x2b44ad[_0x17b6e1[_0x10e183][_0x44c58e(0x15e)]],'%s',_0x1818eb):_0x1818eb,_0x1818eb=_0x17b6e1[_0x10e183]['format']?_[_0x44c58e(0x132)](_0x4678d1[_0x17b6e1[_0x10e183][_0x44c58e(0x127)]],'%s',_0x1818eb):_0x1818eb,_0x17b6e1[_0x10e183][_0x44c58e(0x129)]&&_0x253be7[_0x44c58e(0x14a)](_0x1818eb),_0x17b6e1[_0x10e183][_0x44c58e(0x18d)]&&_0x253be7['order'](_0x1818eb,_0x17b6e1[_0x10e183]['orderBy']===_0x44c58e(0x159)?![]:!![]),_0x253be7[_0x44c58e(0x122)](_0x1818eb,_0x17b6e1[_0x10e183][_0x44c58e(0x118)]||_0x1818eb);}if(_0x267d5d[_0x44c58e(0x150)]){_0x267d5d[_0x44c58e(0x150)]=JSON['parse'](_0x267d5d[_0x44c58e(0x150)]);for(let _0x299a76=0x0;_0x299a76<_0x267d5d[_0x44c58e(0x150)][_0x44c58e(0x165)];_0x299a76+=0x1){_0x267d5d[_0x44c58e(0x150)][_0x299a76][_0x44c58e(0x137)]&&_[_0x44c58e(0x176)](_0x4caa65,_0x267d5d[_0x44c58e(0x150)][_0x299a76][_0x44c58e(0x137)])&&_0x267d5d[_0x44c58e(0x150)][_0x299a76]['parentKey']&&_0x267d5d['joins'][_0x299a76][_0x44c58e(0x12c)]&&_0x267d5d[_0x44c58e(0x150)][_0x299a76]['foreignKey']&&_0x253be7[_0x267d5d['joins'][_0x299a76][_0x44c58e(0x137)]](_0x267d5d[_0x44c58e(0x150)][_0x299a76]['foreignTable'],null,util[_0x44c58e(0x127)]('%s.%s\x20=\x20%s.%s',_0x267d5d[_0x44c58e(0x124)],_0x267d5d['joins'][_0x299a76]['parentKey'],_0x267d5d[_0x44c58e(0x150)][_0x299a76][_0x44c58e(0x12c)],_0x267d5d[_0x44c58e(0x150)][_0x299a76][_0x44c58e(0x166)]));}}return _0x267d5d[_0x44c58e(0x11b)]&&(_0x267d5d[_0x44c58e(0x11b)]=JSON['parse'](_0x267d5d[_0x44c58e(0x11b)]),_0x253be7[_0x44c58e(0x14e)](_0x2b7368(_0x267d5d[_0x44c58e(0x11b)][_0x44c58e(0x14a)]))),_0x23a36d=_0x253be7['clone'](),_0x253be7[_0x44c58e(0x131)](_0x128b6d),_0x253be7['offset'](0x0),logger[_0x44c58e(0x134)](_0x44c58e(0x17a),_0x253be7[_0x44c58e(0x164)]()),db[_0x44c58e(0x123)][_0x44c58e(0x12d)](_0x253be7['toString'](),{'type':QueryTypes['SELECT']});}})[_0xc6b206(0x16d)](function(_0xc30d2){const _0x5a5c00=_0xc6b206;if(!_0xc30d2[_0x5a5c00(0x165)])throw new ValidationErrorItem('No\x20available\x20data',0xcc);if(_0xfe3c45['output']===_0x5a5c00(0x146))return null;const _0x4b9c2a=_[_0x5a5c00(0x16e)](_0xfe3c45,{'name':_0xfe3c45[_0x5a5c00(0x154)]||_0xfe3c45[_0x5a5c00(0x11d)]||_0x267d5d[_0x5a5c00(0x11d)],'basename':_0x50b107,'savename':util[_0x5a5c00(0x127)](_0x5a5c00(0x153),_0xfe3c45[_0x5a5c00(0x11d)]||_0x267d5d['name'],require('randomstring')['generate'](0x4),_0xfe3c45[_0x5a5c00(0x190)]||_0x5a5c00(0x16f)),'reportId':_0x267d5d['id'],'reportType':'default'});return db[_0x5a5c00(0x10d)][_0x5a5c00(0x119)](_0x4b9c2a,{'raw':!![]});})[_0xc6b206(0x16d)](function(_0x4ad0a7){const _0x2a9b80=_0xc6b206;_0x267d5d[_0x2a9b80(0x124)]===_0x2a9b80(0x120)?_0x23a36d[_0x2a9b80(0x14e)](_0x267d5d[_0x2a9b80(0x124)]+_0x2a9b80(0x15c),_0xfe3c45[_0x2a9b80(0x148)],_0xfe3c45[_0x2a9b80(0x17c)]):_0x23a36d[_0x2a9b80(0x14e)](_0x267d5d['table']+_0x2a9b80(0x114),_0xfe3c45[_0x2a9b80(0x148)],_0xfe3c45['endDate']);if(_0x4ad0a7)return logger['info'](_0x2a9b80(0x187),_0x23a36d['toString']()),require('child_process')[_0x2a9b80(0x111)](path['join'](__dirname,'../../components/export/',_0x4ad0a7[_0x2a9b80(0x190)]),[_0x4ad0a7['id'],_0x23a36d[_0x2a9b80(0x164)](),path[_0x2a9b80(0x17b)](__dirname,'../../files/reports',_0x4ad0a7[_0x2a9b80(0x184)]),_0x50b107]),_0x4ad0a7;else{const _0x5130f7=squel['select']();return _0x5130f7[_0x2a9b80(0x12b)]('('+_0x23a36d['toString']()+')',_0x2a9b80(0x109)),_0x5130f7['field']('COUNT(*)',_0x2a9b80(0x158)),_0x23a36d[_0x2a9b80(0x131)](_0xfe3c45[_0x2a9b80(0x131)]||_0x128b6d),_0x23a36d[_0x2a9b80(0x112)](_0xfe3c45[_0x2a9b80(0x112)]||0x0),dbH[_0x2a9b80(0x123)][_0x2a9b80(0x12d)](_0x5130f7[_0x2a9b80(0x164)](),{'type':dbH['sequelize'][_0x2a9b80(0x169)][_0x2a9b80(0x13e)]})['then'](function(_0xe13c4){const _0x591a23=_0x2a9b80;return!_0xe13c4['length']?_0x2b4466=0x0:_0x2b4466=_0xe13c4[0x0][_0x591a23(0x158)]||0x0,dbH[_0x591a23(0x123)][_0x591a23(0x12d)](_0x23a36d[_0x591a23(0x164)](),{'type':dbH[_0x591a23(0x123)]['QueryTypes'][_0x591a23(0x13e)]});})[_0x2a9b80(0x16d)](function(_0x127b2a){return{'rows':_0x127b2a||[],'count':_0x2b4466};});}});}exports[a11_0xc5652e(0x116)]=function(_0x5b5c63,_0x1d7b61){const _0x15be7e=a11_0xc5652e;return runReport(_0x5b5c63['params'],_0x5b5c63['query'],_0x5b5c63['options'])[_0x15be7e(0x16d)](respondWithResult(_0x1d7b61,null))['catch'](handleError(_0x1d7b61,null));},exports[a11_0xc5652e(0x11a)]=runReport,exports[a11_0xc5652e(0x12d)]=function(_0x2061e3,_0x2b9450){const _0x37c8ad=a11_0xc5652e,_0x2b0798=0xa,_0x34bbe7=[_0x37c8ad(0x17b),_0x37c8ad(0x15b),_0x37c8ad(0x16a),_0x37c8ad(0x18f)],_0x1bf808={'SUM':_0x37c8ad(0x174),'COUNT':'COUNT(%s)','COUNT\x20DISTINCT':_0x37c8ad(0x18c),'MAX':_0x37c8ad(0x178),'MIN':'MIN(%s)','AVG':'AVG(%s)','GROUP_CONCAT':_0x37c8ad(0x142),'GROUP_CONCAT\x20ASC':_0x37c8ad(0x106),'GROUP_CONCAT\x20DESC':_0x37c8ad(0x145)},_0x525349={'SEC_TO_TIME':_0x37c8ad(0x115),'DATE':_0x37c8ad(0x121),'HOUR':_0x37c8ad(0x18b),'ROUND':_0x37c8ad(0x10b),'UNIX_TIMESTAMP':'UNIX_TIMESTAMP(%s)'},_0x5f260e=function(_0x17f040){const _0xe0cdef=_0x37c8ad;return!_['includes'](['IS\x20NULL',_0xe0cdef(0x160),'IS\x20EMPTY',_0xe0cdef(0x151)],_0x17f040);},_0x75d8b=function(_0x3d8041){const _0x4ffb0b=_0x37c8ad;if(!_0x3d8041||!_0x3d8041['rules'][_0x4ffb0b(0x165)])return'';let _0xef0a5='(';for(let _0x5d1fb3=0x0;_0x5d1fb3<_0x3d8041[_0x4ffb0b(0x171)][_0x4ffb0b(0x165)];_0x5d1fb3+=0x1){_0x5d1fb3>0x0&&(_0xef0a5+='\x20'+_0x3d8041[_0x4ffb0b(0x13f)]+'\x20'),_0xef0a5+=_0x3d8041['rules'][_0x5d1fb3][_0x4ffb0b(0x14a)]?_0x75d8b(_0x3d8041[_0x4ffb0b(0x171)][_0x5d1fb3]['group']):_0x3d8041['rules'][_0x5d1fb3][_0x4ffb0b(0x122)]+'\x20'+_0x3d8041[_0x4ffb0b(0x171)][_0x5d1fb3]['condition']+(_0x5f260e(_0x3d8041[_0x4ffb0b(0x171)][_0x5d1fb3][_0x4ffb0b(0x108)])?'\x20'+_0x3d8041[_0x4ffb0b(0x171)][_0x5d1fb3][_0x4ffb0b(0x10f)]:'');}return _0xef0a5+')';};let _0x34fba0={'where':{'id':_0x2061e3[_0x37c8ad(0x152)]['id']}},_0x27fa08,_0x28f717,_0xaddc73,_0x3ea140;return _0x34fba0=_[_0x37c8ad(0x16e)]({},_0x34fba0,_0x2061e3['options']),db[_0x37c8ad(0x193)]['findOne'](_0x34fba0)[_0x37c8ad(0x16d)](function(_0x4d8adc){const _0x35d38f=_0x37c8ad;if(_0x4d8adc)return _0x27fa08=_0x4d8adc,_0x4d8adc[_0x35d38f(0x130)]();return null;})[_0x37c8ad(0x16d)](function(_0x27dd01){const _0xa33c2=_0x37c8ad;if(_0x27dd01){if(!_0x27dd01['length'])throw new ValidationErrorItem(_0xa33c2(0x16c),0x193);return _0x28f717=_0x27dd01,db[_0xa33c2(0x117)][_0xa33c2(0x15a)]({'raw':!![]});}return null;})[_0x37c8ad(0x16d)](function(_0x2d730d){const _0x2f4d32=_0x37c8ad;if(_0x2d730d){_0xaddc73=_[_0x2f4d32(0x156)](_0x2d730d,'id');let _0x200480;const _0x326b37=squel[_0x2f4d32(0x110)]();_0x326b37['from'](_0x27fa08[_0x2f4d32(0x124)]);for(let _0x19cdc4=0x0;_0x19cdc4<_0x28f717[_0x2f4d32(0x165)];_0x19cdc4+=0x1){_0x200480=_0x28f717[_0x19cdc4][_0x2f4d32(0x194)]?_0xaddc73[_0x28f717[_0x19cdc4]['MetricId']][_0x2f4d32(0x126)]:_0x28f717[_0x19cdc4][_0x2f4d32(0x122)],_0x200480=_0x28f717[_0x19cdc4][_0x2f4d32(0x15e)]?_[_0x2f4d32(0x132)](_0x1bf808[_0x28f717[_0x19cdc4][_0x2f4d32(0x15e)]],'%s',_0x200480):_0x200480,_0x200480=_0x28f717[_0x19cdc4]['format']?_['replace'](_0x525349[_0x28f717[_0x19cdc4][_0x2f4d32(0x127)]],'%s',_0x200480):_0x200480,_0x28f717[_0x19cdc4][_0x2f4d32(0x129)]&&_0x326b37['group'](_0x200480),_0x28f717[_0x19cdc4][_0x2f4d32(0x18d)]&&_0x326b37[_0x2f4d32(0x185)](_0x200480,_0x28f717[_0x19cdc4][_0x2f4d32(0x18d)]==='DESC'?![]:!![]),_0x326b37[_0x2f4d32(0x122)](_0x200480,_0x28f717[_0x19cdc4]['alias']||_0x200480);}if(_0x27fa08['joins']){_0x27fa08[_0x2f4d32(0x150)]=JSON[_0x2f4d32(0x12e)](_0x27fa08['joins']);for(let _0x35234b=0x0;_0x35234b<_0x27fa08['joins']['length'];_0x35234b+=0x1){_0x27fa08[_0x2f4d32(0x150)][_0x35234b][_0x2f4d32(0x137)]&&_[_0x2f4d32(0x176)](_0x34bbe7,_0x27fa08[_0x2f4d32(0x150)][_0x35234b][_0x2f4d32(0x137)])&&_0x27fa08[_0x2f4d32(0x150)][_0x35234b]['parentKey']&&_0x27fa08[_0x2f4d32(0x150)][_0x35234b][_0x2f4d32(0x12c)]&&_0x27fa08[_0x2f4d32(0x150)][_0x35234b][_0x2f4d32(0x166)]&&_0x326b37[_0x27fa08[_0x2f4d32(0x150)][_0x35234b][_0x2f4d32(0x137)]](_0x27fa08[_0x2f4d32(0x150)][_0x35234b][_0x2f4d32(0x12c)],null,util[_0x2f4d32(0x127)](_0x2f4d32(0x17e),_0x27fa08[_0x2f4d32(0x124)],_0x27fa08[_0x2f4d32(0x150)][_0x35234b]['parentKey'],_0x27fa08[_0x2f4d32(0x150)][_0x35234b][_0x2f4d32(0x12c)],_0x27fa08['joins'][_0x35234b][_0x2f4d32(0x166)]));}}return _0x27fa08['conditions']&&(_0x27fa08[_0x2f4d32(0x11b)]=JSON[_0x2f4d32(0x12e)](_0x27fa08[_0x2f4d32(0x11b)]),_0x326b37[_0x2f4d32(0x14e)](_0x75d8b(_0x27fa08['conditions'][_0x2f4d32(0x14a)]))),_0x3ea140=_0x326b37[_0x2f4d32(0x144)](),_0x326b37[_0x2f4d32(0x131)](_0x2b0798),_0x326b37[_0x2f4d32(0x112)](0x0),logger[_0x2f4d32(0x134)](_0x2f4d32(0x17a),_0x326b37['toString']()),db['sequelize']['query'](_0x326b37[_0x2f4d32(0x164)](),{'type':QueryTypes[_0x2f4d32(0x13e)]});}})[_0x37c8ad(0x16d)](function(){const _0x30b3a6=_0x37c8ad;return{'sql':_0x3ea140[_0x30b3a6(0x164)]()};})['then'](respondWithResult(_0x2b9450,null))[_0x37c8ad(0x139)](handleError(_0x2b9450,null));};
\ No newline at end of file