Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / components / export / csv.js
index fe4228c..1475095 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x99e9=['rimraf','../../mysqldb','../../config/logger','argv','savename','AnalyticExtractedReport','update','info','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','CSV','Setting','find','split','splitSizeCsv','then','query','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','QueryTypes','Empty','length','num','push','sequelize','%s\x20limit\x20%d\x20OFFSET\x20%d','SELECT','dirname','basename','existsSync','join','mkdirSync','each','csv','%s.%s','writeFileSync','zip','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','Completed','catch','Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','inspect','Failed','path','lodash','to-csv','bluebird'];(function(_0x4f7b43,_0x119c22){var _0x2fcdf3=function(_0xaeee0c){while(--_0xaeee0c){_0x4f7b43['push'](_0x4f7b43['shift']());}};_0x2fcdf3(++_0x119c22);}(_0x99e9,0xb4));var _0x999e=function(_0x456a4b,_0x51df8){_0x456a4b=_0x456a4b-0x0;var _0x42957c=_0x99e9[_0x456a4b];return _0x42957c;};'use strict';var util=require('util');var path=require(_0x999e('0x0'));var _=require(_0x999e('0x1'));var csv=require(_0x999e('0x2'));var fs=require('fs');var BPromise=require(_0x999e('0x3'));var zipdir=require('zip-dir');var rimraf=require(_0x999e('0x4'));var db=require(_0x999e('0x5'))['db'];var dbH=require(_0x999e('0x5'))['dbH'];var logger=require(_0x999e('0x6'))('analytics');var EXTRACTED_REPORT_ID=Number(process[_0x999e('0x7')][0x2]);var QUERY=process[_0x999e('0x7')][0x3];var PATH=process[_0x999e('0x7')][0x4];function analyticExtractedReport(_0x18f337,_0x5c1c17){var _0x46aeae={'status':_0x18f337};var _0x38a692={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x5c1c17){_0x46aeae[_0x999e('0x8')]=_0x5c1c17;}return db[_0x999e('0x9')][_0x999e('0xa')](_0x46aeae,_0x38a692);}function main(){var _0x175042=0x1388;var _0x3f2c24;logger[_0x999e('0xb')](util[_0x999e('0xc')](_0x999e('0xd'),EXTRACTED_REPORT_ID,_0x999e('0xe')));return db[_0x999e('0xf')][_0x999e('0x10')]({'where':{'id':0x1},'raw':!![],'attributes':['id',_0x999e('0x11'),_0x999e('0x12')]})[_0x999e('0x13')](function(_0x26b55a){if(_0x26b55a){_0x3f2c24=_0x26b55a;_0x175042=_0x3f2c24['splitSizeCsv']||0x1388;}})[_0x999e('0x13')](function(){return dbH['sequelize'][_0x999e('0x14')](util[_0x999e('0xc')](_0x999e('0x15'),QUERY),{'type':dbH['sequelize'][_0x999e('0x16')]['SELECT']});})[_0x999e('0x13')](function(_0x539598){if(!_0x539598[0x0]['num']){return analyticExtractedReport(_0x999e('0x17'));}var _0x22feac=[];var _0x2dd5f4=0x0;var _0x289e0e=!![];if(_0x539598&&_0x539598[_0x999e('0x18')]){var _0x39ce36=_0x539598[0x0]['num']%(_0x2dd5f4+_0x175042);if(_0x3f2c24['split']){for(;_0x289e0e;_0x2dd5f4+=_0x175042,_0x39ce36=_0x539598[0x0]['num']%(_0x2dd5f4+_0x175042)){if(_0x39ce36==0x0||_0x39ce36==_0x539598[0x0][_0x999e('0x19')]){_0x289e0e=![];}_0x22feac[_0x999e('0x1a')](dbH[_0x999e('0x1b')][_0x999e('0x14')](util[_0x999e('0xc')](_0x999e('0x1c'),QUERY,_0x175042,_0x2dd5f4),{'type':dbH['sequelize']['QueryTypes'][_0x999e('0x1d')]}));}}else{_0x22feac[_0x999e('0x1a')](dbH[_0x999e('0x1b')]['query'](QUERY,{'type':dbH[_0x999e('0x1b')][_0x999e('0x16')][_0x999e('0x1d')]}));}}var _0x36fce4=path[_0x999e('0x1e')](PATH);var _0x3750a0=path[_0x999e('0x1f')](PATH,'.csv');var _0x54ad83=_0x3f2c24[_0x999e('0x11')]&&_0x22feac[_0x999e('0x18')]>0x1;var _0x4c5491=[];if(!fs[_0x999e('0x20')](path[_0x999e('0x21')](_0x36fce4,_0x3750a0))&&_0x54ad83){fs[_0x999e('0x22')](path[_0x999e('0x21')](_0x36fce4,_0x3750a0));}return BPromise[_0x999e('0x23')](_0x22feac,function(_0x320634){_0x4c5491['push'](_0x320634);})[_0x999e('0x13')](function(){for(var _0x4199ff=0x0;_0x4199ff<_0x4c5491[_0x999e('0x18')];_0x4199ff+=0x1){var _0x12b9ad;var _0x1b7adb=_0x4c5491[_0x4199ff];if(_0x54ad83){_0x12b9ad=path[_0x999e('0x21')](_0x36fce4,_0x3750a0,util[_0x999e('0xc')]('%s%d.%s',_0x3750a0,_0x4199ff,_0x999e('0x24')));}else{_0x12b9ad=path['join'](_0x36fce4,util['format'](_0x999e('0x25'),_0x3750a0,_0x999e('0x24')));}fs[_0x999e('0x26')](_0x12b9ad,csv(_0x1b7adb));}})['then'](function(){if(_0x54ad83){zipdir(path[_0x999e('0x21')](_0x36fce4,_0x3750a0),{'saveTo':path[_0x999e('0x21')](_0x36fce4,util[_0x999e('0xc')](_0x999e('0x25'),_0x3750a0,_0x999e('0x27')))},function(_0x327079,_0x82e067){});rimraf(path[_0x999e('0x21')](_0x36fce4,_0x3750a0),function(){});}})[_0x999e('0x13')](function(){logger[_0x999e('0xb')](util['format'](_0x999e('0x28'),EXTRACTED_REPORT_ID,_0x999e('0xe')));return analyticExtractedReport(_0x999e('0x29'),_0x54ad83?util['format'](_0x999e('0x25'),_0x3750a0,_0x54ad83?'zip':'csv'):null);});})[_0x999e('0x2a')](function(_0x332195){logger['info'](util['format'](_0x999e('0x2b'),EXTRACTED_REPORT_ID,_0x999e('0xe')),util[_0x999e('0x2c')](_0x332195,{'showHidden':![],'depth':null}));return analyticExtractedReport(_0x999e('0x2d'));});}main();
\ No newline at end of file
+var _0xb4e6=['splitSizeCsv','then','sequelize','query','SELECT\x20count(*)\x20as\x20num\x20FROM\x20(%s)\x20t','SELECT','num','Empty','split','push','%s\x20limit\x20%d\x20OFFSET\x20%d','QueryTypes','dirname','basename','.csv','length','existsSync','mkdirSync','join','each','csv','%s.%s','writeFileSync','zip','Extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format\x20completed','Completed','catch','CSV','inspect','Failed','util','lodash','to-csv','bluebird','zip-dir','rimraf','../../mysqldb','../../config/logger','analytics','argv','AnalyticExtractedReport','update','info','format','Start\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format','Setting','find'];(function(_0x38d7fe,_0x283ce3){var _0x33d4a7=function(_0xc3d4de){while(--_0xc3d4de){_0x38d7fe['push'](_0x38d7fe['shift']());}};_0x33d4a7(++_0x283ce3);}(_0xb4e6,0x1f4));var _0x6b4e=function(_0x350aeb,_0x3d265a){_0x350aeb=_0x350aeb-0x0;var _0x3c5273=_0xb4e6[_0x350aeb];return _0x3c5273;};'use strict';var util=require(_0x6b4e('0x0'));var path=require('path');var _=require(_0x6b4e('0x1'));var csv=require(_0x6b4e('0x2'));var fs=require('fs');var BPromise=require(_0x6b4e('0x3'));var zipdir=require(_0x6b4e('0x4'));var rimraf=require(_0x6b4e('0x5'));var db=require(_0x6b4e('0x6'))['db'];var dbH=require(_0x6b4e('0x6'))['dbH'];var logger=require(_0x6b4e('0x7'))(_0x6b4e('0x8'));var EXTRACTED_REPORT_ID=Number(process[_0x6b4e('0x9')][0x2]);var QUERY=process['argv'][0x3];var PATH=process[_0x6b4e('0x9')][0x4];function analyticExtractedReport(_0x570346,_0x4f00be){var _0x2311d9={'status':_0x570346};var _0x48c870={'where':{'id':EXTRACTED_REPORT_ID}};if(_0x4f00be){_0x2311d9['savename']=_0x4f00be;}return db[_0x6b4e('0xa')][_0x6b4e('0xb')](_0x2311d9,_0x48c870);}function main(){var _0x1e3bf6=0x1388;var _0x39ed74;logger[_0x6b4e('0xc')](util[_0x6b4e('0xd')](_0x6b4e('0xe'),EXTRACTED_REPORT_ID,'CSV'));return db[_0x6b4e('0xf')][_0x6b4e('0x10')]({'where':{'id':0x1},'raw':!![],'attributes':['id','split',_0x6b4e('0x11')]})[_0x6b4e('0x12')](function(_0x432399){if(_0x432399){_0x39ed74=_0x432399;_0x1e3bf6=_0x39ed74[_0x6b4e('0x11')]||0x1388;}})[_0x6b4e('0x12')](function(){return dbH[_0x6b4e('0x13')][_0x6b4e('0x14')](util['format'](_0x6b4e('0x15'),QUERY),{'type':dbH[_0x6b4e('0x13')]['QueryTypes'][_0x6b4e('0x16')]});})['then'](function(_0x355f10){if(!_0x355f10[0x0][_0x6b4e('0x17')]){return analyticExtractedReport(_0x6b4e('0x18'));}var _0x42e265=[];var _0x28c3ba=0x0;var _0x135568=!![];if(_0x355f10&&_0x355f10['length']){var _0x5775f4=_0x355f10[0x0][_0x6b4e('0x17')]%(_0x28c3ba+_0x1e3bf6);if(_0x39ed74[_0x6b4e('0x19')]){for(;_0x135568;_0x28c3ba+=_0x1e3bf6,_0x5775f4=_0x355f10[0x0][_0x6b4e('0x17')]%(_0x28c3ba+_0x1e3bf6)){if(_0x5775f4==0x0||_0x5775f4==_0x355f10[0x0][_0x6b4e('0x17')]){_0x135568=![];}_0x42e265[_0x6b4e('0x1a')](dbH[_0x6b4e('0x13')][_0x6b4e('0x14')](util[_0x6b4e('0xd')](_0x6b4e('0x1b'),QUERY,_0x1e3bf6,_0x28c3ba),{'type':dbH[_0x6b4e('0x13')][_0x6b4e('0x1c')]['SELECT']}));}}else{_0x42e265[_0x6b4e('0x1a')](dbH[_0x6b4e('0x13')][_0x6b4e('0x14')](QUERY,{'type':dbH[_0x6b4e('0x13')]['QueryTypes'][_0x6b4e('0x16')]}));}}var _0x507703=path[_0x6b4e('0x1d')](PATH);var _0x163dea=path[_0x6b4e('0x1e')](PATH,_0x6b4e('0x1f'));var _0xa06ccd=_0x39ed74[_0x6b4e('0x19')]&&_0x42e265[_0x6b4e('0x20')]>0x1;var _0x5c33be=[];if(!fs[_0x6b4e('0x21')](path['join'](_0x507703,_0x163dea))&&_0xa06ccd){fs[_0x6b4e('0x22')](path[_0x6b4e('0x23')](_0x507703,_0x163dea));}return BPromise[_0x6b4e('0x24')](_0x42e265,function(_0xdba4fe){_0x5c33be['push'](_0xdba4fe);})[_0x6b4e('0x12')](function(){for(var _0x3f72d7=0x0;_0x3f72d7<_0x5c33be['length'];_0x3f72d7+=0x1){var _0x32102f;var _0x381ff0=_0x5c33be[_0x3f72d7];if(_0xa06ccd){_0x32102f=path[_0x6b4e('0x23')](_0x507703,_0x163dea,util[_0x6b4e('0xd')]('%s%d.%s',_0x163dea,_0x3f72d7,_0x6b4e('0x25')));}else{_0x32102f=path[_0x6b4e('0x23')](_0x507703,util['format'](_0x6b4e('0x26'),_0x163dea,_0x6b4e('0x25')));}fs[_0x6b4e('0x27')](_0x32102f,csv(_0x381ff0));}})[_0x6b4e('0x12')](function(){if(_0xa06ccd){zipdir(path['join'](_0x507703,_0x163dea),{'saveTo':path[_0x6b4e('0x23')](_0x507703,util[_0x6b4e('0xd')]('%s.%s',_0x163dea,_0x6b4e('0x28')))},function(_0x3f9868,_0x37b636){});rimraf(path['join'](_0x507703,_0x163dea),function(){});}})['then'](function(){logger[_0x6b4e('0xc')](util[_0x6b4e('0xd')](_0x6b4e('0x29'),EXTRACTED_REPORT_ID,'CSV'));return analyticExtractedReport(_0x6b4e('0x2a'),_0xa06ccd?util[_0x6b4e('0xd')](_0x6b4e('0x26'),_0x163dea,_0xa06ccd?'zip':'csv'):null);});})[_0x6b4e('0x2b')](function(_0x4952ef){logger[_0x6b4e('0xc')](util[_0x6b4e('0xd')]('Error\x20during\x20extraction\x20report\x20with\x20id\x20%d\x20in\x20%s\x20format',EXTRACTED_REPORT_ID,_0x6b4e('0x2c')),util[_0x6b4e('0x2d')](_0x4952ef,{'showHidden':![],'depth':null}));return analyticExtractedReport(_0x6b4e('0x2e'));});}main();
\ No newline at end of file