diff --git a/scripts/add_recording.php b/scripts/add_recording.php deleted file mode 100644 index eb8a374..0000000 --- a/scripts/add_recording.php +++ /dev/null @@ -1,31 +0,0 @@ -insertContingent($contingent); - - Printer::println("Дозапись выполнена!", Color::BLUE); -} catch (\Exception $e) { - Printer::println($e->getMessage(), Color::RED); - exit(0); -} diff --git a/scripts/contingent_parser.php b/scripts/contingent_parser.php index 0d8e08c..58c0567 100644 --- a/scripts/contingent_parser.php +++ b/scripts/contingent_parser.php @@ -2,7 +2,9 @@ use SvedenParser\Color; use SvedenParser\ContingentParser\ContingentManager; +use SvedenParser\ContingentParser\ContingentRepository; use SvedenParser\Printer; +use SvedenParser\Repository; use Symfony\Component\Yaml\Yaml; define('SVEDEN_PARSER', '/home/developer/sveden_parser'); @@ -23,4 +25,23 @@ for ($i = $start; $i < $end; $i++) { $manager->collectData($sites[--$i]); } Printer::println(); -// require __DIR__ . "/add_recording.php"; \ No newline at end of file + +try { + if (!file_exists(Repository::FILE_ADD_RECORDING)) { + throw new Exception( + "Файл " . Repository::FILE_ADD_RECORDING + . " не обнаружен. Дозапись в базу не требуется" + ); + } + + $contingent = Yaml::parse( + file_get_contents(SVEDEN_PARSER . '/' . Repository::FILE_ADD_RECORDING) + ); + $databaseFacade = new ContingentRepository(); + $databaseFacade->insert($contingent); + + Printer::println("Дозапись выполнена!", Color::BLUE); +} catch (\Exception $e) { + Printer::println($e->getMessage(), Color::RED); + exit(0); +} \ No newline at end of file diff --git a/scripts/priem_parser.php b/scripts/priem_parser.php index e955da0..b4a2754 100644 --- a/scripts/priem_parser.php +++ b/scripts/priem_parser.php @@ -1,7 +1,9 @@ getSites(); // $sites = Yaml::parse(file_get_contents(dirname(__FILE__) ."/sites.yaml")); -$start = 8; $end = count($sites); +$start = 0; $end = count($sites); // $start = 0; $end = (int)(count($sites) / 2); // $start = (int)(count($sites) / 2); $end = count($sites); @@ -21,4 +23,24 @@ for ($i = $start; $i < $end; $i++) { Printer::print(++$i . ". ", Color::GREEN); $manager->collectData($sites[--$i]); } -Printer::println(); \ No newline at end of file +Printer::println(); + +try { + if (!file_exists(Repository::FILE_ADD_RECORDING)) { + throw new Exception( + "Файл " . Repository::FILE_ADD_RECORDING + . " не обнаружен. Дозапись в базу не требуется" + ); + } + + $priem = Yaml::parse( + file_get_contents(SVEDEN_PARSER . '/' . Repository::FILE_ADD_RECORDING) + ); + $databaseFacade = new PriemRepository(); + $databaseFacade->insert($priem); + + Printer::println("Дозапись выполнена!", Color::BLUE); +} catch (\Exception $e) { + Printer::println($e->getMessage(), Color::RED); + exit(0); +} \ No newline at end of file diff --git a/scripts/script.php b/scripts/script.php deleted file mode 100644 index ddbd210..0000000 --- a/scripts/script.php +++ /dev/null @@ -1,65 +0,0 @@ -getSites(); -$all = array_column($sourceAll, 'org_id'); // все организации -$inBase = $facade->getOrgInOpendata(); // организации уже в базе -$httpAndHtml = array_values(array_diff($all, $inBase)); -echo "ALL". PHP_EOL; -print_r($httpAndHtml); -$http = getErrorSites('log/http-curl.log'); -$html = getErrorSites('log/html.log'); -$http = array_values(array_diff($httpAndHtml, $html)); -write('sites-html.log', $html); -write('sites-http.log', $http); -// echo "HTML". PHP_EOL; -// print_r($html); -// echo "HTTP". PHP_EOL; -// print_r($http); -// echo "REMAINS". PHP_EOL; -// $remains = array_values(array_diff($httpAndHtml, array_merge($html, $http))); -// print_r($remains); -// echo "EMPTY". PHP_EOL; -// $empty = emptySites($sourceAll, $remains); -// print_r($empty); -// // $fall = array_values(array_diff($remains, $empty)); -// // print_r($fall); -// write('sites-html.log', $html); -// write('sites-http.log', $http); \ No newline at end of file diff --git a/src/PriemParser/PriemRow.php b/src/PriemParser/PriemRow.php index 411c532..dabb49b 100644 --- a/src/PriemParser/PriemRow.php +++ b/src/PriemParser/PriemRow.php @@ -32,7 +32,7 @@ class PriemRow 'spec_name' => $this->eduName, 'edu_level' => $this->eduLevel, 'edu_forms'=> $this->eduForm, - 'avgScore' => $this->avgScore, + 'avg_score' => $this->avgScore, 'contongent' => $this->all, 'budget' => $this->budget, ]; @@ -45,7 +45,7 @@ class PriemRow foreach ($contingent as $key => $con) { $all += (int)$con; if ($key !== 3) { - $budget += $con; + $budget += (int)$con; } } $this->all = $all;