|
|
@@ -914,7 +914,7 @@ function validateCompany(source) {
|
|
|
}
|
|
|
return $refsTables;
|
|
|
} catch (Exception $e) {
|
|
|
- echo "{$namespace} - {$e->getMessage}";
|
|
|
+// echo "{$namespace} - {$e->getMessage}";
|
|
|
return [];
|
|
|
}
|
|
|
}
|
|
|
@@ -1288,7 +1288,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function reloadCache_updateAll($full = false) {
|
|
|
+ private function reloadCache_updateAll($full, $onlyBase) {
|
|
|
$tablesConf = [
|
|
|
'BI_audit_CEIDG' => [
|
|
|
'fields' => [
|
|
|
@@ -1469,17 +1469,18 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
foreach ($tablesConf as $table => $tableConf) if (!$tableConf['base']) $queries[] = "update `{$table}` set `cached` = 0";
|
|
|
$queries[] = "delete from BI_audit_ALL where BASE = 0";
|
|
|
$queries[] = "delete from BI_audit_ALL_ref where BASE = 0";
|
|
|
- }
|
|
|
|
|
|
- foreach ($refTablesConf as $refTableFrom => $refTableConf) {
|
|
|
- if ($refTableConf['base']) continue;
|
|
|
- foreach ($refTableConf['refTablesTo'] as $refTableTo) {
|
|
|
- $refTable = ACL::getRefTable("default_db/{$refTableFrom}/{$refTableFrom}", "default_db__x3A__{$refTableTo}:{$refTableTo}");
|
|
|
- $queries[] = "update `{$refTable}` set `A_STATUS` = 'WAITNG' where `A_STATUS` = 'NORMAL'";
|
|
|
+ foreach ($refTablesConf as $refTableFrom => $refTableConf) {
|
|
|
+ if ($refTableConf['base']) continue;
|
|
|
+ foreach ($refTableConf['refTablesTo'] as $refTableTo) {
|
|
|
+ $refTable = ACL::getRefTable("default_db/{$refTableFrom}/{$refTableFrom}", "default_db__x3A__{$refTableTo}:{$refTableTo}");
|
|
|
+ $queries[] = "update `{$refTable}` set `A_STATUS` = 'WAITNG' where `A_STATUS` = 'NORMAL'";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
foreach ($tablesConf as $table => $tableConf) {
|
|
|
+ if ($onlyBase && (!$tableConf['base'])) continue;
|
|
|
$where = "where `cached` = 0";
|
|
|
if (!empty($tableConf['where'])) $where .= " {$tableConf['where']}";
|
|
|
// $queries[] = "lock tables `{$table}` write";
|
|
|
@@ -1504,6 +1505,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
$queries[] = "insert into `BI_audit_ALL_ref_RELATIONS` (`ID`, `RELATION`, `BASE`) select @var:=@var*2, `a`.`RELATION`, `a`.`BASE` from (select `a`.`REMOTE_TABLE` as `RELATION`, `a`.`BASE` as `BASE` from `BI_audit_ALL` `a` where `a`.`REMOTE_TABLE` not in ('BI_audit_ENERGA_RUM_KONTRAHENCI', 'BI_audit_KW_requested_person') group by `a`.`REMOTE_TABLE` order by `a`.`BASE` desc) as `a` left join `BI_audit_ALL_ref_RELATIONS` `r` on `a`.`RELATION` = `r`.`RELATION` where `r`.`RELATION` is null";
|
|
|
|
|
|
foreach ($refTablesConf as $refTableFrom => $refTableConf) {
|
|
|
+ if ($onlyBase && (!$tableConf['base'])) continue;
|
|
|
foreach ($refTableConf['refTablesTo'] as $refTableTo) {
|
|
|
$refTable = ACL::getRefTable("default_db/{$refTableFrom}/{$refTableFrom}", "default_db__x3A__{$refTableTo}:{$refTableTo}");
|
|
|
// $queries[] = "lock tables `{$refTable}` write";
|
|
|
@@ -1515,10 +1517,13 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
// $queries[] = "unlock tables";
|
|
|
}
|
|
|
}
|
|
|
- echo implode(";\n", $queries) . ";\n";
|
|
|
- foreach ($queries as $query) DB::getPDO()->query($query);
|
|
|
+// echo implode(";\n", $queries) . ";\n";
|
|
|
+ foreach ($queries as $query) {
|
|
|
+ echo "SQL: {$query}\n";
|
|
|
+ DB::getPDO()->query($query);
|
|
|
+ }
|
|
|
|
|
|
- $BiAuditRelations = new BiAuditRelations($full);
|
|
|
+ $BiAuditRelations = new BiAuditRelations();
|
|
|
// DB::getPDO()->query("lock tables `BI_audit_ALL` write");
|
|
|
$result = DB::getPDO()->query("select `ID` from `BI_audit_ALL` where `reffed` = 0 order by `ID`");
|
|
|
while ($row = $result->fetch()) $BiAuditRelations->findRelations($row['ID']);
|
|
|
@@ -1527,6 +1532,12 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
}
|
|
|
|
|
|
public function doReloadCache($full = false) {
|
|
|
+ if ($full == 'base') {
|
|
|
+ $onlyBase = true;
|
|
|
+ $full = false;
|
|
|
+ } else {
|
|
|
+ $onlyBase = false;
|
|
|
+ }
|
|
|
$powiazaniaDirLocation = $this->getMainDirectory();
|
|
|
$tasksDirLocation = $powiazaniaDirLocation . "/.tasks";
|
|
|
$reloadCachePidFile = $tasksDirLocation . "/reloadCache.pid";
|
|
|
@@ -1534,7 +1545,7 @@ Router::getRoute("UrlAction_BiAuditGenerate")->' . $function . ';
|
|
|
file_put_contents($reloadCachePidFile, getmypid());
|
|
|
try {
|
|
|
$this->reloadCache_reTeryt($full);
|
|
|
- $this->reloadCache_updateAll($full);
|
|
|
+ $this->reloadCache_updateAll($full, $onlyBase);
|
|
|
file_put_contents($reloadCacheResultFile, "ok");
|
|
|
} catch (Exception $e) {
|
|
|
file_put_contents($reloadCacheResultFile, $e->getMessage());
|
|
|
@@ -1622,7 +1633,6 @@ SQL;
|
|
|
|
|
|
class BiAuditRelations {
|
|
|
private $RELATIONS_ID = [];
|
|
|
- private $full;
|
|
|
|
|
|
private $relations = [
|
|
|
'nip' => ['nip'],
|