Skip to content
Snippets Groups Projects
Commit 6884e0ef authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Recalcul des vues matérialisées lors de la mise à jour

parent 3ae2d042
Branches
Tags
1 merge request!55Ll bug report services
......@@ -3,6 +3,7 @@
## Nouveautés
* Les modèles de pièces justificatives peuvent être téléchargés en fonction de l'année courante (paramètre :annee à ajouter dans l'URL qui sera remplacé dynamiquement par l'année en cours)
* Les vues matérialisées sont recalculées à chaque mise à jour
## Notes de mise à jour
......
......@@ -63,6 +63,8 @@ $dataGen->update();
$c->println('');
$mm->migration('post');
// Recalcul des vues matérialisées
$bdd->refreshMaterializedViews();
// Néttoyage des caches
$oa->run('clear-cache');
\ No newline at end of file
......@@ -680,6 +680,29 @@ class Bdd
public function refreshMaterializedViews($ddl = null)
{
if (!$ddl) {
$ddl = $this->materializedView()->get();
} else {
$ddl = Ddl::normalize($ddl)->get(Ddl::MATERIALIZED_VIEW);
if (!$ddl) $ddl = [];
}
$this->logBegin("Recalcul de toutes les vues matérialisées");
foreach ($ddl as $mv) {
try {
$this->logMsg("Vue matérialisée " . $mv['name'] . " ...", true);
$this->materializedView()->refresh($mv);
} catch (\Throwable $e) {
$this->logError($e);
}
}
$this->logEnd();
}
/**
* @return array
* @throws BddCompileException
......
......@@ -100,4 +100,18 @@ class MaterializedViewManager extends AbstractManager implements MaterializedVie
$this->drop($oldName);
$this->create($new);
}
/**
* @param string|array $name
*/
public function refresh($name)
{
if (is_array($name)) {
$name = $name['name'];
}
$this->addQuery("BEGIN DBMS_SNAPSHOT.REFRESH( '$name','C'); END;", 'Mise à jour de la vue matérialisée ' . $name);
}
}
\ No newline at end of file
......@@ -4,5 +4,8 @@ namespace BddAdmin\Manager;
interface MaterializedViewManagerInteface extends ManagerInterface
{
/**
* @param string|array $name
*/
public function refresh($name);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment