[misc] add table action increase sync.

This commit is contained in:
qixinzhi
2024-09-27 09:45:55 +08:00
committed by 宋辰轩
parent 43a18cf36c
commit a26decaa37
3 changed files with 10 additions and 1 deletions
+1
View File
@@ -195,6 +195,7 @@ class duckdb
$sql = preg_replace($ztpattern, $replace, $sql);
$sql = preg_replace($ztvpattern, $replace, $sql);
$sql = str_replace('zt_action.parquet', 'zt_action_*.parquet', $sql);
$sql = str_replace('__biPath__', $this->tmpPath, $sql);
return $sql;
}
+1 -1
View File
@@ -14,7 +14,7 @@ $config->bi->conditionList['NOT IN'] = 'NOT IN';
$config->bi->conditionList['IS NOT NULL'] = 'IS NOT NULL';
$config->bi->conditionList['IS NULL'] = 'IS NULL';
$config->bi->duckdbExcludeTables = array('metriclib', 'repofiles', 'repohistory', 'queue', 'duckdbqueue', '');
$config->bi->duckdbExcludeTables = array('metriclib', 'repofiles', 'repohistory', 'queue', 'duckdbqueue', 'action');
$config->bi->builtin = new stdclass();
$config->bi->builtin->modules = new stdclass();
+8
View File
@@ -1193,6 +1193,11 @@ class biModel extends model
$copySQLs = array();
foreach($tables as $table) $copySQLs[] = "copy (select * from {$table}) to '{$duckdbTmpPath}{$table}.parquet'";
$date = date("Y-m-01 00:00:00");
$prefix = $this->config->db->prefix;
$copySQLs[] = "copy (select * from {$prefix}action where date < TIMESTAMP '$date') to '{$duckdbTmpPath}{$prefix}action_" . date('Y_m', strtotime('-1 month')) . ".parquet'";
$copySQL = implode(';', $copySQLs);
if(empty($copySQL)) return true;
@@ -1219,6 +1224,9 @@ class biModel extends model
$copySQLs = array();
foreach($tables as $table) $copySQLs[] = "copy (select * from {$table}) to '{$duckdbTmpPath}{$table}.parquet'";
$actions = $this->getActionSyncSql();
foreach($actions as $table => $sql) $copySQLs[] = "copy ({$sql}) to '{$duckdbTmpPath}{$table}.parquet'";
$this->biTao->updateSyncTime($tables);
return implode(';', $copySQLs);