From 8509b73f00ed182feeb72663ea892438235efac9 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Sat, 11 May 2024 05:43:55 +0000 Subject: [PATCH] * Add import bi data in step 5. --- module/install/control.php | 2 ++ module/install/model.php | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/module/install/control.php b/module/install/control.php index 722c61306c..1beb0ed872 100644 --- a/module/install/control.php +++ b/module/install/control.php @@ -382,6 +382,8 @@ class install extends control /* Update created date of metrics. */ $this->loadModel('metric')->updateMetricDate(); + $this->install->importBIData(); + $skipApp = (string)getenv('ZT_SKIP_DEVOPS_INIT'); $link = ($this->config->inQuickon && (!$skipApp || $skipApp == 'false')) ? inlink('app') : inlink('step6'); return $this->send(array('result' => 'success', 'load' => $link)); diff --git a/module/install/model.php b/module/install/model.php index a70c9d013d..5f86c4beec 100644 --- a/module/install/model.php +++ b/module/install/model.php @@ -107,6 +107,8 @@ class installModel extends model $dbFile = $this->app->getAppRoot() . 'db' . DS . 'zentao.sql'; $tables = explode(';', file_get_contents($dbFile)); + + foreach($tables as $table) { $table = trim($table); @@ -371,4 +373,42 @@ class installModel extends model return true; } + + /** + * 导入BI内置数据。 + * Import BI data. + * + * @access public + * @return bool + */ + public function importBIData() + { + $this->loadModel('bi'); + + /* Prepare built-in sqls of bi. */ + $chartSQLs = $this->bi->prepareBuiltinChartSQL(); + $pivotSQLs = $this->bi->prepareBuiltinPivotSQL(); + + $insertTables = array_merge($chartSQLs, $pivotSQLs); + + try + { + foreach($insertTables as $table) + { + $table = trim($table); + if(empty($table)) continue; + + $table = str_replace('`zt_', $this->config->db->name . '.`zt_', $table); + $table = str_replace('zt_', $this->config->db->prefix, $table); + if(!$this->dbh->query($table)) return false; + } + } + catch(Error $e) + { + a($e->getMessage()); + die; + } + + return true; + } }