Built motion from commit f861bcb808219e66da88ba48b61bddb35224a65e. Version 3.0.0...
[motion-next.git] / server / components / export / export-report.js
diff --git a/server/components/export/export-report.js b/server/components/export/export-report.js
new file mode 100644 (file)
index 0000000..fca307b
--- /dev/null
@@ -0,0 +1 @@
+'use strict';const a992_0x1c5a=['analytics','16661bbbjiQ','\x20in\x20','ensureDir','fs-extra','205959EKVkHw','Unsupported\x20format:\x20\x22','SIGINT','Error\x20during\x20extraction\x20of\x20report\x20with\x20id\x20','524403EQtzbm','Empty\x20Query\x20=\x20','../../globals','58GJAMTc','basename','.zip','xlsx','Starting\x20main:\x20args\x20=\x20','join','./lib/pdf','\x20format\x20completed','bind','3CQATPd','dirname','error','Name:','debug','zip-dir','Report\x20','\x20produced\x20successfully\x20to\x20','./lib/csv','uncaughtException','309263rxohpt','toUpperCase','info','path','Extraction\x20report\x20with\x20id\x20','\x20format','./lib/xlsx','argv','csv','11491RWGivh','Export\x20process\x20failed','pdf','52531EmjdgK','@config/logger','exit','success','Start\x20extraction\x20report\x20with\x20id\x20','unhandledRejection','81RvJadd','@utils/console-logger','fatal','Destination:','@mysqldb','686451qImxaa','remove','./lib/common','length','message','zip'];const a992_0x1b4e=function(_0x4c66b0,_0x344aa7){_0x4c66b0=_0x4c66b0-0x92;let _0x1c5a98=a992_0x1c5a[_0x4c66b0];return _0x1c5a98;};const a992_0xfab501=a992_0x1b4e;(function(_0x1aacab,_0x4ffb2a){const _0x21af0b=a992_0x1b4e;while(!![]){try{const _0x4bceeb=parseInt(_0x21af0b(0xcb))*-parseInt(_0x21af0b(0xc0))+-parseInt(_0x21af0b(0xab))*-parseInt(_0x21af0b(0xb4))+parseInt(_0x21af0b(0xb9))+-parseInt(_0x21af0b(0x98))*parseInt(_0x21af0b(0xae))+-parseInt(_0x21af0b(0xa2))+-parseInt(_0x21af0b(0xc4))+parseInt(_0x21af0b(0xc8));if(_0x4bceeb===_0x4ffb2a)break;else _0x1aacab['push'](_0x1aacab['shift']());}catch(_0x3ed30c){_0x1aacab['push'](_0x1aacab['shift']());}}}(a992_0x1c5a,0x7aac8));require(a992_0xfab501(0xca));const path=require(a992_0xfab501(0xa5)),fs=require(a992_0xfab501(0xc3)),zipdir=require(a992_0xfab501(0x9d)),{db}=require(a992_0xfab501(0xb8)),logger=require(a992_0xfab501(0xaf))(a992_0xfab501(0xbf)),{consoleLogger}=require(a992_0xfab501(0xb5)),{generatePDFReport}=require(a992_0xfab501(0x95)),{generateCSVReport}=require(a992_0xfab501(0xa0)),{generateXSLXReport}=require(a992_0xfab501(0xa8)),{analyticExtractedReport,chunkReportQuery,generateFileName,getSettings}=require(a992_0xfab501(0xbb));async function exportReport(_0x1966eb,_0x1f0204,_0x1d9b5b,_0x21bb89,_0x10fcda){const _0x4061ef=a992_0xfab501;let _0x313b6c='';try{const _0x4d41cf=path[_0x4061ef(0x99)](_0x21bb89),_0x25710f=path[_0x4061ef(0xcc)](_0x21bb89,'.'+_0x1966eb),{setting:_0x5b863f,limit:_0x20d7c5}=await getSettings(_0x1966eb),{queryResults:_0x497665,mustChunkResults:_0x40388b}=await chunkReportQuery(_0x1d9b5b,_0x5b863f,_0x20d7c5);if(_0x497665['length']>0x0){await fs[_0x4061ef(0xc2)](_0x40388b?path[_0x4061ef(0x94)](_0x4d41cf,_0x25710f):_0x4d41cf);const _0x22de55=generateFileName[_0x4061ef(0x97)](this,_0x4d41cf,_0x25710f,_0x1966eb,_0x40388b);let _0x5aac0b=null;switch(_0x1966eb){case _0x4061ef(0xaa):await generateCSVReport(_0x497665,_0x22de55);break;case _0x4061ef(0xad):await generatePDFReport(_0x1f0204,_0x497665,_0x10fcda,_0x22de55,db);break;case _0x4061ef(0x92):await generateXSLXReport(_0x497665,_0x22de55);break;default:_0x5aac0b=new Error(_0x4061ef(0xc5)+_0x1966eb+'\x22');break;}if(_0x5aac0b)throw _0x5aac0b;if(_0x40388b){const _0x8cf242=path[_0x4061ef(0x94)](_0x4d41cf,_0x25710f),_0x3d1fe5=path['join'](_0x4d41cf,_0x25710f+_0x4061ef(0xcd));await zipdir(_0x8cf242,{'saveTo':_0x3d1fe5}),await fs[_0x4061ef(0xba)](_0x8cf242);}logger[_0x4061ef(0xa4)](_0x4061ef(0xa6)+_0x1f0204+_0x4061ef(0xc1)+_0x1966eb[_0x4061ef(0xa3)]()+_0x4061ef(0x96)),_0x313b6c=_0x25710f+'.'+(_0x40388b?_0x4061ef(0xbe):_0x1966eb);}}catch(_0x146260){logger['error'](_0x4061ef(0xc7)+_0x1f0204+_0x4061ef(0xc1)+_0x1966eb[_0x4061ef(0xa3)]()+_0x4061ef(0xa7),_0x146260);throw _0x146260;}return _0x313b6c;}async function main(_0x4c03a1,_0x147422,_0x87a942,_0x78c5aa,_0xc23bcf=''){const _0x10c543=a992_0xfab501;try{logger['info'](_0x10c543(0xb2)+_0x147422+_0x10c543(0xc1)+_0x4c03a1[_0x10c543(0xa3)]()+_0x10c543(0xa7)),consoleLogger['debug'](_0x10c543(0x93),_0x4c03a1,_0x147422,_0x87a942),consoleLogger['debug'](_0x10c543(0xb7),_0x78c5aa),consoleLogger['debug'](_0x10c543(0x9b),_0xc23bcf);const _0x3f0564=await exportReport(_0x4c03a1,_0x147422,_0x87a942,_0x78c5aa,_0xc23bcf);_0x3f0564?.[_0x10c543(0xbc)]>0x0?(await analyticExtractedReport(_0x147422,'Completed',_0x3f0564),consoleLogger[_0x10c543(0xb1)](_0x10c543(0x9e)+_0x147422+_0x10c543(0x9f)+_0x78c5aa)):(await analyticExtractedReport(_0x147422,'Empty'),consoleLogger['warn'](_0x10c543(0x9e)+_0x147422+'\x20not\x20produced\x20(empty)'),consoleLogger[_0x10c543(0x9c)](_0x10c543(0xc9)+_0x87a942));}catch(_0x2e16d0){await analyticExtractedReport(_0x147422,'Failed'),consoleLogger[_0x10c543(0xb6)](_0x10c543(0xac),_0x2e16d0);throw _0x2e16d0;}}function handleUncaughtException(_0x9fa897){const _0x3dc106=a992_0xfab501;consoleLogger[_0x3dc106(0x9a)](_0x9fa897[_0x3dc106(0xbd)]);throw _0x9fa897;}function handleStop(){const _0x311b1f=a992_0xfab501;consoleLogger[_0x311b1f(0x9c)]('Received\x20SIGINT'),process[_0x311b1f(0xb0)](0x82);}process['on'](a992_0xfab501(0xc6),handleStop),process['on'](a992_0xfab501(0xa1),handleUncaughtException),process['on'](a992_0xfab501(0xb3),handleUncaughtException);const FORMAT=process[a992_0xfab501(0xa9)][0x2],EXTRACTED_REPORT_ID=Number(process[a992_0xfab501(0xa9)][0x3]),QUERY=process[a992_0xfab501(0xa9)][0x4],PATH=process[a992_0xfab501(0xa9)][0x5],NAME=process['argv'][0x6];main(FORMAT,EXTRACTED_REPORT_ID,QUERY,PATH,NAME);
\ No newline at end of file