Built motion from commit d13e3c905.|1.0.24
[motion.git] / server / api / custom_report / custom_report.controller.js
1 var _0xda11=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x75\x73\x74\x6F\x6D\x52\x65\x70\x6F\x72\x74","\x52\x65\x70\x6F\x72\x74\x46\x69\x65\x6C\x64","\x4D\x65\x74\x72\x69\x63","\x45\x78\x74\x72\x61\x63\x74\x65\x64\x52\x65\x70\x6F\x72\x74","\x2E\x2E\x2F\x2E\x2E\x2F\x75\x74\x69\x6C\x73\x2F\x72\x65\x70\x6F\x72\x74\x5F\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E","\x2E\x2E\x2F\x2E\x2E\x2F\x75\x74\x69\x6C\x73\x2F\x72\x65\x70\x6F\x72\x74\x5F\x62\x75\x69\x6C\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x73\x69\x6D\x70\x6C\x65\x2D\x72\x61\x6E\x64\x6F\x6D","\x6D\x6F\x6D\x65\x6E\x74","\x63\x68\x69\x6C\x64\x5F\x70\x72\x6F\x63\x65\x73\x73","\x52\x65\x70\x6F\x72\x74\x54\x72\x65\x65","\x61\x70\x69","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x6C\x6F\x67\x67\x65\x72\x2E\x6A\x73","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x67\x65\x74\x52\x65\x70\x6F\x72\x74\x51\x75\x65\x72\x79","\x45\x72\x72\x6F\x72\x20\x67\x65\x74\x74\x69\x6E\x67\x20\x71\x75\x65\x72\x79\x20\x66\x72\x6F\x6D\x20\x61\x70\x69\x3A","\x73\x74\x61\x63\x6B","\x65\x72\x72\x6F\x72","\x6E\x6F\x20\x73\x75\x66\x66\x69\x63\x69\x65\x6E\x74\x20\x71\x75\x65\x75\x65\x20\x70\x65\x72\x6D\x69\x73\x73\x69\x6F\x6E\x73\x20\x66\x6F\x72\x20\x74\x68\x65\x20\x75\x73\x65\x72","\x70\x65\x72\x6D\x69\x73\x73\x69\x6F\x6E","\x61\x6C\x6C","\x62\x75\x69\x6C\x64\x51\x75\x65\x72\x79","\x73\x70\x72\x65\x61\x64","\x75\x73\x65\x72","\x62\x75\x69\x6C\x64\x46\x69\x6C\x74\x65\x72","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x64\x61\x69\x6C\x79","\x74\x72\x75\x65","\x73\x74\x61\x72\x74\x44\x61\x74\x65","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44","\x66\x6F\x72\x6D\x61\x74","\x65\x6E\x64\x44\x61\x74\x65","\x74\x61\x62\x6C\x65","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x5F\x68\x69\x73\x74\x6F\x72\x79","","\x72\x65\x70\x6C\x61\x63\x65","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x66\x69\x65\x6C\x64\x73","\x73\x63\x6F\x70\x65","\x70\x72\x65\x76\x69\x65\x77","\x69\x73\x41\x72\x72\x61\x79","\x6C\x65\x6E\x67\x74\x68","\x6C\x69\x6D\x69\x74","\x76\x61\x6C\x75\x65","\x74\x61\x6B\x65","\x6F\x66\x66\x73\x65\x74","\x73\x6C\x69\x63\x65","\x59\x59\x59\x59\x2D\x4D\x4D\x2D\x44\x44\x20\x48\x48\x3A\x6D\x6D\x3A\x73\x73","\x66\x6F\x72\x4F\x77\x6E","\x66\x6F\x72\x45\x61\x63\x68","\x71\x75\x65\x72\x79\x20\x65\x72\x72\x6F\x72","\x63\x68\x65\x63\x6B\x51\x75\x65\x72\x79","\x65\x78\x74\x72\x61\x63\x74\x50\x64\x66","\x65\x78\x74\x72\x61\x63\x74\x50\x64\x66\x20\x61\x70\x69\x20\x66\x75\x6E\x63\x74\x69\x6F\x6E","\x64\x65\x62\x75\x67","\x50\x44\x46","\x65\x78\x74\x72\x61\x63\x74\x43\x73\x76","\x65\x78\x74\x72\x61\x63\x74\x43\x73\x76\x20\x61\x70\x69\x20\x66\x75\x6E\x63\x74\x69\x6F\x6E","\x43\x53\x56","\x64\x65\x73\x74\x72\x6F\x79\x4E\x6F\x64\x65\x52\x65\x70\x6F\x72\x74\x73","\x74\x72\x65\x65","\x70\x61\x72\x73\x65","\x66\x69\x6E\x64","\x4E\x6F\x64\x65\x20\x6E\x6F\x74\x20\x66\x6F\x75\x6E\x64","\x64\x65\x73\x74\x72\x6F\x79","\x70\x75\x73\x68","\x66\x69\x6C\x74\x65\x72","\x63\x6F\x6D\x6D\x6F\x6E\x20\x64\x6F\x63\x45\x78\x74\x72\x61\x63\x74\x20\x61\x70\x69\x20\x66\x75\x6E\x63\x74\x69\x6F\x6E","\x43\x72\x65\x61\x74\x65\x64\x20\x6E\x65\x77\x20\x65\x78\x74\x72\x61\x63\x74\x65\x64\x20\x72\x65\x70\x6F\x72\x74\x73\x20\x64\x62\x20\x65\x6E\x74\x72\x79\x2C\x20\x63\x61\x6C\x6C\x69\x6E\x67\x20\x65\x78\x74\x65\x72\x6E\x61\x6C\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x20\x66\x75\x6E\x63\x74\x69\x6F\x6E\x3A\x20","\x2F\x2E\x2E\x2F\x2E\x2E\x2F\x75\x74\x69\x6C\x73\x2F\x72\x65\x70\x6F\x72\x74\x5F\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x2E\x6A\x73","\x66\x6F\x72\x6B","\x52\x65\x70\x6F\x72\x74\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x20\x70\x72\x6F\x63\x65\x73\x73\x20\x65\x72\x72\x6F\x72","\x6F\x6E","\x63\x6C\x6F\x73\x65","\x52\x65\x70\x6F\x72\x74\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x20\x70\x72\x6F\x63\x65\x73\x73\x20\x63\x6C\x6F\x73\x65","\x6D\x65\x73\x73\x61\x67\x65","\x52\x65\x70\x6F\x72\x74\x20\x65\x78\x74\x72\x61\x63\x74\x69\x6F\x6E\x20\x70\x72\x6F\x63\x65\x73\x73\x20\x6D\x65\x73\x73\x61\x67\x65","\x6B\x69\x6C\x6C","\x70\x61\x72\x65\x6E\x74","\x6E\x61\x6D\x65","\x46\x6F\x75\x6E\x64\x20\x74\x68\x65\x20\x72\x65\x70\x6F\x72\x74\x2C\x20\x63\x72\x65\x61\x74\x69\x6E\x67\x20\x74\x68\x65\x20\x6E\x65\x77\x20\x44\x42\x20\x72\x6F\x77\x20\x66\x6F\x72\x20\x65\x78\x74\x72\x61\x63\x74\x65\x64\x20\x72\x65\x70\x6F\x72\x74\x73\x2E\x2E","\x73\x74\x61\x72\x74\x54\x69\x6D\x65","\x20","\x30\x30\x3A\x30\x30","\x65\x6E\x64\x54\x69\x6D\x65","\x32\x33\x3A\x35\x39","\x63\x72\x65\x61\x74\x65","\x74\x65\x78\x74","\x2F\x20","\x23","\x73\x68\x6F\x77","\x65\x78\x70\x6F\x72\x74","\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E\x73","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","\x65\x78\x70\x6F\x72\x74\x46\x69\x65\x6C\x64\x73","\x63\x6F\x70\x79","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x75\x70\x64\x61\x74\x65\x64\x41\x74","\x62\x6F\x64\x79","\x6D\x61\x70","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x46\x69\x65\x6C\x64\x73","\x69\x6D\x70\x6F\x72\x74","\x75\x70\x64\x61\x74\x65","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x67\x65\x74\x54\x61\x62\x6C\x65","\x43\x75\x73\x74\x6F\x6D\x52\x65\x70\x6F\x72\x74\x49\x64","\x4D\x65\x74\x72\x69\x63\x49\x64","\x66\x69\x65\x6C\x64","\x6D\x65\x74\x72\x69\x63","\x54\x68\x65\x20\x6D\x65\x74\x72\x69\x63\x20\x77\x69\x74\x68\x20\x69\x64\x20","\x20\x79\x6F\x75\x20\x73\x70\x65\x63\x69\x66\x69\x65\x64\x20\x64\x6F\x65\x73\x20\x6E\x6F\x74\x20\x65\x78\x69\x73\x74","\x69\x6E\x63\x6C\x75\x64\x65\x73","\x63\x75\x73\x74\x6F\x6D","\x54\x68\x65\x20\x66\x69\x65\x6C\x64\x20","\x20\x79\x6F\x75\x20\x73\x70\x65\x63\x69\x66\x69\x65\x64\x20\x64\x6F\x65\x73\x20\x6E\x6F\x74\x20\x65\x78\x69\x73\x74\x20\x69\x6E\x20\x74\x68\x65\x20\x74\x61\x62\x6C\x65","\x6B\x65\x79\x73","\x66\x69\x6E\x64\x41\x6C\x6C","\x64\x65\x73\x63\x72\x69\x62\x65","\x59\x6F\x75\x20\x68\x61\x76\x65\x20\x6E\x6F\x74\x20\x73\x70\x65\x63\x69\x66\x69\x65\x64\x20\x74\x68\x65\x20\x74\x61\x62\x6C\x65\x20\x6F\x72\x20\x74\x68\x65\x20\x74\x61\x62\x6C\x65\x20\x64\x6F\x65\x73\x20\x6E\x6F\x74\x20\x65\x78\x69\x73\x74","\x44\x65\x66\x61\x75\x6C\x74\x4D\x65\x74\x72\x69\x63\x49\x64","\x68\x61\x73","\x65\x76\x65\x72\x79","\x44\x65\x66\x61\x75\x6C\x74\x4D\x65\x74\x72\x69\x63","\x55\x6E\x73\x75\x70\x70\x6F\x72\x74\x65\x64\x20\x49\x6D\x70\x6F\x72\x74\x20\x66\x6F\x72\x6D\x61\x74\x20\x28\x4D\x65\x74\x72\x69\x63\x20\x74\x79\x70\x65\x20\x69\x6E\x20\x72\x65\x70\x6F\x72\x74\x20\x66\x69\x65\x6C\x64\x73\x20\x69\x73\x20\x6D\x69\x73\x73\x69\x6E\x67\x29","\x49\x64","\x67\x72\x6F\x75\x70\x42\x79","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x6E\x75\x6C\x6C","\x52\x65\x70\x6F\x72\x74\x46\x69\x65\x6C\x64\x73","\x5F","\x62\x75\x6C\x6B\x44\x65\x73\x74\x72\x6F\x79","\x69\x64\x73"];_0xda11[0];var _=require(_0xda11[1]);var util=require(_0xda11[2]);var sequelize=require(_0xda11[4])[_0xda11[3]];var CustomReport=require(_0xda11[4])[_0xda11[5]];var ReportField=require(_0xda11[4])[_0xda11[6]];var Metric=require(_0xda11[4])[_0xda11[7]];var ExtractedReport=require(_0xda11[4])[_0xda11[8]];var extractUtils=require(_0xda11[9]);var reportBuildUtils=require(_0xda11[10]);var Util=require(_0xda11[11]);var sr=require(_0xda11[12]);var moment=require(_0xda11[13]);var cp=require(_0xda11[14]);var ReportTree=require(_0xda11[4])[_0xda11[15]];var logger=require(_0xda11[17])(_0xda11[16]);exports[_0xda11[18]]= function(_0x2807x10,_0x2807x11,_0x2807x12){return CustomReport[_0xda11[25]](Util[_0xda11[24]](_0x2807x10[_0xda11[23]],{deletedAt:null}))[_0xda11[22]](function(_0x2807x14){_0x2807x11[_0xda11[21]](200)[_0xda11[20]](_0x2807x14)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};exports[_0xda11[26]]= function(_0x2807x10,_0x2807x11){return Promise[_0xda11[32]]([])[_0xda11[22]](getQuery(_0x2807x10,_0x2807x11))[_0xda11[22]](function(_0x2807x15){if(_0x2807x15){switch(_0x2807x15){case _0xda11[31]:_0x2807x15= _0xda11[30];break;default:}};_0x2807x11[_0xda11[21]](200)[_0xda11[20]]({query:_0x2807x15})})[_0xda11[19]](function(_0x2807x13){logger[_0xda11[29]](_0xda11[27],_0x2807x13[_0xda11[28]])})};function getQuery(_0x2807x10,_0x2807x11){var _0x2807x17;return function(){return CustomReport[_0xda11[53]](_0xda11[52])[_0xda11[51]](_0x2807x10[_0xda11[50]][_0xda11[49]])[_0xda11[22]](function(_0x2807x19){if(!_0x2807x19){return _0x2807x11[_0xda11[37]](404)};if(_0x2807x10[_0xda11[23]][_0xda11[38]]&& _0x2807x10[_0xda11[23]][_0xda11[38]]=== _0xda11[39]){_0x2807x10[_0xda11[23]][_0xda11[40]]= moment()[_0xda11[42]](_0xda11[41]);_0x2807x10[_0xda11[23]][_0xda11[43]]= moment()[_0xda11[42]](_0xda11[41]);_0x2807x19[_0xda11[45]][_0xda11[44]]= _0x2807x19[_0xda11[45]][_0xda11[44]][_0xda11[48]](_0xda11[46],_0xda11[47])};delete _0x2807x10[_0xda11[23]][_0xda11[38]];_0x2807x17= _0x2807x19[_0xda11[45]];return _0x2807x17[_0xda11[44]]})[_0xda11[22]](reportBuildUtils[_0xda11[36]](_0x2807x10[_0xda11[35]]))[_0xda11[22]](function(_0x2807x18){return [_0x2807x18,_0x2807x17]})[_0xda11[34]](reportBuildUtils[_0xda11[33]](_0x2807x10[_0xda11[23]]))}}exports[_0xda11[54]]= function(_0x2807x10,_0x2807x11){var _0x2807x1a;return Promise[_0xda11[32]]([])[_0xda11[22]](getQuery(_0x2807x10,_0x2807x11))[_0xda11[22]](reportBuildUtils[_0xda11[66]]())[_0xda11[22]](function(_0x2807x1b){if(_0x2807x1b&& _[_0xda11[55]](_0x2807x1b)){_0x2807x1a= _0x2807x1b[_0xda11[56]];if(_0x2807x10[_0xda11[23]][_0xda11[57]]){_0x2807x1b= _(_0x2807x1b)[_0xda11[61]](_0x2807x10[_0xda11[23]][_0xda11[60]]|| 0)[_0xda11[59]](_0x2807x10[_0xda11[23]][_0xda11[57]])[_0xda11[58]]()};_[_0xda11[64]](_0x2807x1b,function(_0x2807x1c){_[_0xda11[63]](_0x2807x1c,function(_0x2807x1d,_0x2807x1e){if(_0x2807x1d instanceof  Date){_0x2807x1c[_0x2807x1e]= moment(_0x2807x1d)[_0xda11[42]](_0xda11[62]).toString()}})});_0x2807x11[_0xda11[21]](200)[_0xda11[20]]({rows:_0x2807x1b,count:_0x2807x1a})}else {return handleError(_0x2807x11,{message:_0x2807x1b|| _0xda11[65]})}})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};exports[_0xda11[67]]= function(_0x2807x10,_0x2807x11){logger[_0xda11[69]](_0xda11[68]);docExtract(_0x2807x10,_0x2807x11,_0xda11[70])};exports[_0xda11[71]]= function(_0x2807x10,_0x2807x11){logger[_0xda11[69]](_0xda11[72]);docExtract(_0x2807x10,_0x2807x11,_0xda11[73])};exports[_0xda11[74]]= function(_0x2807x10,_0x2807x11){return ReportTree[_0xda11[51]](2)[_0xda11[22]](function(_0x2807x1f){_0x2807x1f= JSON[_0xda11[76]](_0x2807x1f[_0xda11[75]]);var _0x2807x20=_[_0xda11[77]](_0x2807x1f,{id:_0x2807x10[_0xda11[50]][_0xda11[49]]});if(!_0x2807x20){throw  new Error(_0xda11[78])};var _0x2807x21=[];findSubNodes(_0x2807x20,_0x2807x1f,_0x2807x21);return CustomReport[_0xda11[79]]({where:{parent:_0x2807x21},individualHooks:true})})[_0xda11[22]](function(){return _0x2807x11[_0xda11[37]](200)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};function findSubNodes(_0x2807x20,_0x2807x1f,_0x2807x23){_0x2807x23[_0xda11[80]](_0x2807x20[_0xda11[49]]);var _0x2807x24=_[_0xda11[81]](_0x2807x1f,{parent:_0x2807x20[_0xda11[49]]});if(!_0x2807x24||  !_0x2807x24[_0xda11[56]]){return};_[_0xda11[64]](_0x2807x24,function(_0x2807x25){findSubNodes(_0x2807x25,_0x2807x1f,_0x2807x23)})}function docExtract(_0x2807x10,_0x2807x11,_0x2807x27){var _0x2807x19;logger[_0xda11[69]](_0xda11[82]);CustomReport[_0xda11[53]](_0xda11[52])[_0xda11[51]](_0x2807x10[_0xda11[50]][_0xda11[49]])[_0xda11[22]](function(_0x2807x17){if(!_0x2807x17){return _0x2807x11[_0xda11[37]](404)};_0x2807x19= _0x2807x17;return ReportTree[_0xda11[51]](2)})[_0xda11[22]](function(_0x2807x1f){_0x2807x1f= JSON[_0xda11[76]](_0x2807x1f[_0xda11[75]]);var _0x2807x2b=_[_0xda11[77]](_0x2807x1f,{id:_0x2807x19[_0xda11[93]]});var _0x2807x2c=getReportPath(_0x2807x2b,_0x2807x1f,_0x2807x19[_0xda11[94]]);logger[_0xda11[69]](_0xda11[95]);if(_0x2807x10[_0xda11[23]][_0xda11[38]]&& _0x2807x10[_0xda11[23]][_0xda11[38]]=== _0xda11[39]){_0x2807x10[_0xda11[23]][_0xda11[40]]= moment()[_0xda11[42]](_0xda11[41]);_0x2807x10[_0xda11[23]][_0xda11[43]]= moment()[_0xda11[42]](_0xda11[41]);_0x2807x19[_0xda11[45]][_0xda11[44]]= _0x2807x19[_0xda11[45]][_0xda11[44]][_0xda11[48]](_0xda11[46],_0xda11[47])};delete _0x2807x10[_0xda11[23]][_0xda11[38]];return [_0x2807x19,ExtractedReport[_0xda11[101]]({name:_0x2807x2c,startDate:_0x2807x10[_0xda11[23]][_0xda11[40]]?_0x2807x10[_0xda11[23]][_0xda11[40]]+ (_0x2807x10[_0xda11[23]][_0xda11[96]]?_0xda11[97]+ _0x2807x10[_0xda11[23]][_0xda11[96]]:_0xda11[98]):null,endDate:_0x2807x10[_0xda11[23]][_0xda11[43]]?_0x2807x10[_0xda11[23]][_0xda11[43]]+ (_0x2807x10[_0xda11[23]][_0xda11[99]]?_0xda11[97]+ _0x2807x10[_0xda11[23]][_0xda11[99]]:_0xda11[100]):null,output:_0x2807x27,UserId:_0x2807x10[_0xda11[35]][_0xda11[49]]})]})[_0xda11[34]](function(_0x2807x19,_0x2807x28){logger[_0xda11[69]](_0xda11[83]+ _0x2807x27);var _0x2807x29=cp[_0xda11[85]](__dirname+ _0xda11[84]);_0x2807x29[_0xda11[87]](_0xda11[90],function(_0x2807x2a){logger[_0xda11[69]](_0xda11[91],_0x2807x2a);_0x2807x29[_0xda11[92]]()})[_0xda11[87]](_0xda11[88],function(){logger[_0xda11[69]](_0xda11[89])})[_0xda11[87]](_0xda11[29],function(_0x2807x13){logger[_0xda11[69]](_0xda11[86],_0x2807x13)});_0x2807x29[_0xda11[20]]({report:_0x2807x19,query:_0x2807x10[_0xda11[23]],extractedId:_0x2807x28[_0xda11[49]],user:_0x2807x10[_0xda11[35]],type:_0x2807x27})})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)});return _0x2807x11[_0xda11[37]](200)}function getReportPath(_0x2807x2b,_0x2807x1f,_0x2807x2c){_0x2807x2c= _0x2807x2b[_0xda11[102]]+ _0xda11[103]+ _0x2807x2c;if(_0x2807x2b[_0xda11[93]]=== _0xda11[104]){return _0x2807x2c}else {return getReportPath(_[_0xda11[77]](_0x2807x1f,{id:_0x2807x2b[_0xda11[93]]}),_0x2807x1f,_0x2807x2c)}}exports[_0xda11[105]]= function(_0x2807x10,_0x2807x11){return CustomReport[_0xda11[53]](_0xda11[52])[_0xda11[51]](_0x2807x10[_0xda11[50]][_0xda11[49]])[_0xda11[22]](function(_0x2807x19){if(!_0x2807x19){return _0x2807x11[_0xda11[37]](404)};return _0x2807x11[_0xda11[20]](_0x2807x19)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};exports[_0xda11[106]]= function(_0x2807x10,_0x2807x11){return CustomReport[_0xda11[53]]({method:[_0xda11[109],{CustomReportId:_0x2807x10[_0xda11[50]][_0xda11[49]]}]})[_0xda11[51]](_0x2807x10[_0xda11[50]][_0xda11[49]],{attributes:[_0xda11[107],_0xda11[108],_0xda11[94],_0xda11[93],_0xda11[44]]})[_0xda11[22]](function(_0x2807x19){if(!_0x2807x19){return _0x2807x11[_0xda11[37]](404)};return _0x2807x11[_0xda11[20]](_0x2807x19)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};exports[_0xda11[110]]= function(_0x2807x10,_0x2807x11){var _0x2807x2e;return sequelize[_0xda11[115]](function(_0x2807x2f){return CustomReport[_0xda11[53]](_0xda11[52])[_0xda11[51]](_0x2807x10[_0xda11[50]][_0xda11[49]])[_0xda11[22]](function(_0x2807x19){if(!_0x2807x19){return _0x2807x11[_0xda11[37]](404)};var _0x2807x30=_0x2807x19[_0xda11[45]];delete _0x2807x30[_0xda11[49]];delete _0x2807x30[_0xda11[111]];delete _0x2807x30[_0xda11[112]];_0x2807x30[_0xda11[93]]= _0x2807x10[_0xda11[113]][_0xda11[93]];_0x2807x2e= _[_0xda11[114]](_0x2807x30.Fields,_0xda11[45]);return CustomReport[_0xda11[101]](_0x2807x30,{transaction:_0x2807x2f})})[_0xda11[22]](function(_0x2807x19){return [_0x2807x19,_0x2807x2e]})[_0xda11[34]](createFields(_0x2807x2f))})[_0xda11[22]](function(){return _0x2807x11[_0xda11[37]](201)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};exports[_0xda11[101]]= function(_0x2807x10,_0x2807x11){var _0x2807x17;return sequelize[_0xda11[115]](function(_0x2807x2f){return CustomReport[_0xda11[101]](_0x2807x10[_0xda11[113]],{transaction:_0x2807x2f})[_0xda11[22]](function(_0x2807x19){_0x2807x17= _0x2807x19;return [_0x2807x17,_0x2807x10[_0xda11[113]][_0xda11[116]]]})[_0xda11[34]](createFields(_0x2807x2f))})[_0xda11[22]](function(){return _0x2807x11[_0xda11[21]](201)[_0xda11[20]](_0x2807x17)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};exports[_0xda11[117]]= function(_0x2807x10,_0x2807x11){var _0x2807x17;return sequelize[_0xda11[115]](function(_0x2807x2f){return CustomReport[_0xda11[101]](_0x2807x10[_0xda11[113]],{transaction:_0x2807x2f})[_0xda11[22]](function(_0x2807x19){_0x2807x17= _0x2807x19;return [_0x2807x17,_0x2807x10[_0xda11[113]][_0xda11[116]]]})[_0xda11[34]](createImportFields(_0x2807x2f))})[_0xda11[22]](function(){return _0x2807x11[_0xda11[21]](201)[_0xda11[20]](_0x2807x17)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};exports[_0xda11[118]]= function(_0x2807x10,_0x2807x11,_0x2807x12){if(_0x2807x10[_0xda11[113]][_0xda11[49]]){delete _0x2807x10[_0xda11[113]][_0xda11[49]]};var _0x2807x17;return sequelize[_0xda11[115]](function(_0x2807x2f){return CustomReport[_0xda11[51]](_0x2807x10[_0xda11[50]][_0xda11[49]])[_0xda11[22]](function(_0x2807x19){if(!_0x2807x19){return _0x2807x11[_0xda11[37]](404)};var _0x2807x31=_[_0xda11[119]](_0x2807x19,_0x2807x10[_0xda11[113]]);return _0x2807x19[_0xda11[120]]({transaction:_0x2807x2f})})[_0xda11[22]](function(_0x2807x19){_0x2807x17= _0x2807x19;if(_0x2807x10[_0xda11[113]][_0xda11[116]]){return ReportField[_0xda11[79]]({where:{CustomReportId:_0x2807x10[_0xda11[50]][_0xda11[49]]},transaction:_0x2807x2f})}})[_0xda11[22]](function(){return [_0x2807x17,_0x2807x10[_0xda11[113]][_0xda11[116]]]})[_0xda11[34]](createFields(_0x2807x2f))})[_0xda11[22]](function(){return _0x2807x11[_0xda11[37]](200)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};function createFields(_0x2807x2f){return function(_0x2807x19,_0x2807x33){if(_0x2807x33&& Array[_0xda11[55]](_0x2807x33)&& _0x2807x33[_0xda11[56]]){var _0x2807x34=reportBuildUtils[_0xda11[121]](_0x2807x19[_0xda11[44]]);if(_0x2807x34){var _0x2807x35;return _0x2807x34[_0xda11[134]]()[_0xda11[22]](function(_0x2807x3a){_0x2807x35= _[_0xda11[132]](_0x2807x3a);return Metric[_0xda11[133]]()})[_0xda11[22]](function(_0x2807x36){var _0x2807x37=[];_0x2807x36= _[_0xda11[114]](_0x2807x36,_0xda11[45]);_0x2807x33[_0xda11[64]](function(_0x2807x38){_0x2807x38[_0xda11[122]]= _0x2807x19[_0xda11[49]];if(_0x2807x38[_0xda11[123]]){var _0x2807x39=_[_0xda11[77]](_0x2807x36,{id:_0x2807x38[_0xda11[123]]});if(_0x2807x39){_0x2807x38[_0xda11[124]]= _0x2807x39[_0xda11[125]];_0x2807x37[_0xda11[80]](ReportField[_0xda11[101]](_0x2807x38,{transaction:_0x2807x2f}))}else {throw  new sequelize.Error(_0xda11[126]+ _0x2807x38[_0xda11[123]]+ _0xda11[127])}}else {if(_[_0xda11[128]](_0x2807x35,_0x2807x38[_0xda11[124]])|| _0x2807x38[_0xda11[129]]){_0x2807x37[_0xda11[80]](ReportField[_0xda11[101]](_0x2807x38,{transaction:_0x2807x2f}))}else {throw  new sequelize.Error(_0xda11[130]+ _0x2807x38[_0xda11[124]]+ _0xda11[131])}}});return _0x2807x37})[_0xda11[32]]()}else {throw  new sequelize.Error(_0xda11[135])}}}}function createImportFields(_0x2807x2f){return function(_0x2807x19,_0x2807x33){if(_0x2807x33&& Array[_0xda11[55]](_0x2807x33)&& _0x2807x33[_0xda11[56]]){var _0x2807x34=reportBuildUtils[_0xda11[121]](_0x2807x19[_0xda11[44]]);if(_0x2807x34){var _0x2807x35;return _0x2807x34[_0xda11[134]]()[_0xda11[22]](function(_0x2807x3a){_0x2807x35= _[_0xda11[132]](_0x2807x3a);var _0x2807x37=[];var _0x2807x3c;if(_[_0xda11[138]](_0x2807x33,function(_0x2807x38){return _[_0xda11[137]](_0x2807x38,_0xda11[136])})){_0x2807x3c= _0xda11[139]}else {if(_[_0xda11[138]](_0x2807x33,function(_0x2807x38){return _[_0xda11[137]](_0x2807x38,_0xda11[123])})){_0x2807x3c= _0xda11[7]}else {throw  new sequelize.Error(_0xda11[140])}};var _0x2807x3d=_[_0xda11[142]](_0x2807x33,_0x2807x3c+ _0xda11[141]);_[_0xda11[63]](_0x2807x3d,function(_0x2807x3e,_0x2807x1e){if(_0x2807x1e!== _0xda11[143]&& _0x2807x1e!== _0xda11[144]){_0x2807x3e[0][_0x2807x3c][_0xda11[145]][_0xda11[64]](function(_0x2807x38){_0x2807x38[_0xda11[122]]= _0x2807x19[_0xda11[49]]});_0x2807x3e[0][_0x2807x3c][_0xda11[94]]+= _0xda11[146]+ sr({length:5});_0x2807x37[_0xda11[80]](Metric[_0xda11[101]](_0x2807x3e[0][_0x2807x3c],{include:[{model:ReportField,as:_0xda11[145]}],transaction:_0x2807x2f}))}else {_0x2807x3e[_0xda11[64]](function(_0x2807x38){if(_[_0xda11[128]](_0x2807x35,_0x2807x38[_0xda11[124]])|| _0x2807x38[_0xda11[129]]){_0x2807x38[_0xda11[122]]= _0x2807x19[_0xda11[49]];_0x2807x37[_0xda11[80]](ReportField[_0xda11[101]](_0x2807x38,{transaction:_0x2807x2f}))}else {throw  new sequelize.Error(_0xda11[130]+ _0x2807x38[_0xda11[124]]+ _0xda11[131])}})}});return _0x2807x37})[_0xda11[32]]()}else {throw  new sequelize.Error(_0xda11[135])}}}}exports[_0xda11[79]]= function(_0x2807x10,_0x2807x11){return CustomReport[_0xda11[51]](_0x2807x10[_0xda11[50]][_0xda11[49]])[_0xda11[22]](function(_0x2807x19){if(!_0x2807x19){return _0x2807x11[_0xda11[37]](404)};return _0x2807x19[_0xda11[79]]()})[_0xda11[22]](function(){return _0x2807x11[_0xda11[37]](204)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};exports[_0xda11[147]]= function(_0x2807x10,_0x2807x11){return CustomReport[_0xda11[79]]({where:{id:_0x2807x10[_0xda11[23]][_0xda11[148]]},individualHooks:true})[_0xda11[22]](function(){return _0x2807x11[_0xda11[37]](204)})[_0xda11[19]](function(_0x2807x13){return handleError(_0x2807x11,_0x2807x13)})};function handleError(_0x2807x11,_0x2807x13){logger[_0xda11[29]](_0x2807x13[_0xda11[28]]);return _0x2807x11[_0xda11[21]](500)[_0xda11[20]](_0x2807x13)}