Procházet zdrojové kódy

split openassos and opentalent queries

Olivier Massot před 3 roky
rodič
revize
f218c8f092

+ 0 - 21
src/Commands/BindfileRefreshCommand.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace App\Commands;
-
-use Symfony\Component\Console\Attribute\AsCommand;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
-
-#[AsCommand(
-    name: 'opentalent:bindfile-refresh',
-    description: 'Refresh the content of /etc/bind/zones/opentalent.fr.db with the latest data from opentalent.Subdomain'
-)]
-class BindfileRefreshCommand extends Command
-{
-    protected function execute(InputInterface $input, OutputInterface $output): int
-    {
-        throw new \RuntimeException('not implemented yet');
-        return Command::SUCCESS;
-    }
-}

+ 12 - 4
src/Commands/PostUpgrade/V0_2/PostUpgradeCommand.php

@@ -68,12 +68,20 @@ class PostUpgradeCommand extends Command
             }
 
             $this->logger->info('Populate Subdomain table from openassos.sys_domain');
-            $sql = "INSERT INTO opentalent.Subdomain (organization_id, subdomain)
-                    SELECT o.id, REGEXP_REPLACE(d.domainName, '^(.+)\\\\.opentalent\\\\.fr$', '\\\\1')
+
+            $sql = "SELECT d.pid, REGEXP_REPLACE(d.domainName, '^(.+)\\\\.opentalent\\\\.fr$', '\\\\1')
                     FROM openassos.sys_domain d
-                    inner join opentalent.Organization o on o.cmsId = d.pid
                     where d.domainName like '%.opentalent.fr';";
-            $cnn->query($sql);
+            $statement = $cnn->query($sql);
+
+            foreach ($statement->fetchAll() as $row) {
+                [$cmsId, $subdomain] = $row;
+                $sql = "INSERT INTO opentalent.Subdomain (organization_id, subdomain)
+                    SELECT o.id, " . $subdomain . "
+                    from opentalent.Organization o 
+                    where o.cmsId = " . $cmsId . ";";
+                $cnn->query($sql);
+            }
 
             $sql = "delete 
                     from opentalent.Subdomain