* [story#59956,0.5h] refactor generateParquetFile.
This commit is contained in:
+6
-24
@@ -22,35 +22,17 @@ class bi extends control
|
||||
public function syncParquetFile()
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
$duckdb = $this->bi->getDuckDBPath();
|
||||
if(!$duckdb)
|
||||
{
|
||||
echo("DuckDB bin path not exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
$duckdbTmpPath = $this->bi->getDuckDBTmpDir();
|
||||
if(!$duckdbTmpPath)
|
||||
{
|
||||
echo("Create DuckDB tmp dir permission denied.");
|
||||
return;
|
||||
}
|
||||
|
||||
$copySQL = $this->bi->prepareCopySQL($duckdbTmpPath);
|
||||
$command = $this->bi->prepareSyncCommand($duckdb->bin, $duckdb->extension, $copySQL);
|
||||
|
||||
$output = shell_exec($command);
|
||||
$endTime = microtime(true);
|
||||
$runTime = $endTime - $startTime;
|
||||
$result = $this->bi->generateParquetFile();
|
||||
$endTime = microtime(true);
|
||||
$runTime = $endTime - $startTime;
|
||||
echo "$runTime \n";
|
||||
|
||||
if(empty($output))
|
||||
if($result !== true)
|
||||
{
|
||||
echo('success');
|
||||
echo $result;
|
||||
return;
|
||||
}
|
||||
|
||||
echo($output);
|
||||
echo 'success';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+18
-1
@@ -829,9 +829,10 @@ class biModel extends model
|
||||
* @access public
|
||||
* @return string|false
|
||||
*/
|
||||
public function getDuckDBTmpDir()
|
||||
public function getDuckDBTmpDir($static = false)
|
||||
{
|
||||
$duckdbTmpPath = $this->app->getTmpRoot() . 'duckdb' . DS . 'bi' . DS;
|
||||
if($static) return $duckdbTmpPath;
|
||||
if(!is_dir($duckdbTmpPath) && !mkdir($duckdbTmpPath, 0755, true)) return false;
|
||||
|
||||
return $duckdbTmpPath;
|
||||
@@ -910,6 +911,22 @@ class biModel extends model
|
||||
return "$sqlContent 2>&1";
|
||||
}
|
||||
|
||||
public function generateParquetFile()
|
||||
{
|
||||
$duckdb = $this->getDuckDBPath();
|
||||
if(!$duckdb) return $this->lang->bi->binNotExists;
|
||||
|
||||
$duckdbTmpPath = $this->getDuckDBTmpDir();
|
||||
if(!$duckdbTmpPath) return sprintf($this->lang->bi->tmpPermissionDenied, $this->getDuckDBTmpDir(true), $this->getDuckDBTmpDir(true));
|
||||
|
||||
$copySQL = $this->prepareCopySQL($duckdbTmpPath);
|
||||
$command = $this->prepareSyncCommand($duckdb->bin, $duckdb->extension, $copySQL);
|
||||
$output = shell_exec($command);
|
||||
if(!empty($output)) return $output;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process filter variables in sql.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user