убрал лишнее
This commit is contained in:
parent
3b6fecec6c
commit
277ce3bb70
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* При ошибке в запросе к БД. Распарсингованные данные
|
||||
* сохраняются в yaml-файле. Скрипт парсит этот файл и заносит в БД
|
||||
*/
|
||||
use SvedenParser\Color;
|
||||
use SvedenParser\ContingentParser\ContingentRepository;
|
||||
use SvedenParser\Printer;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
require_once __DIR__ . "/vendor/autoload.php";
|
||||
|
||||
try {
|
||||
if (!file_exists(ContingentRepository::FILE_ADD_RECORDING)) {
|
||||
throw new Exception(
|
||||
"Файл " . ContingentRepository::FILE_ADD_RECORDING
|
||||
. " не обнаружен. Дозапись в базу не требуется"
|
||||
);
|
||||
}
|
||||
|
||||
$contingent = Yaml::parse(
|
||||
file_get_contents(__DIR__ . '/' . ContingentRepository::FILE_ADD_RECORDING)
|
||||
);
|
||||
$databaseFacade = new ContingentRepository();
|
||||
$databaseFacade->insertContingent($contingent);
|
||||
|
||||
Printer::println("Дозапись выполнена!", Color::BLUE);
|
||||
} catch (\Exception $e) {
|
||||
Printer::println($e->getMessage(), Color::RED);
|
||||
exit(0);
|
||||
}
|
@ -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";
|
||||
|
||||
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);
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
use SvedenParser\Color;
|
||||
use SvedenParser\PriemParser\PriemManager;
|
||||
use SvedenParser\PriemParser\PriemRepository;
|
||||
use SvedenParser\Printer;
|
||||
use SvedenParser\Repository;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
|
||||
@ -13,7 +15,7 @@ $manager = new PriemManager();
|
||||
$sites = $manager->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);
|
||||
|
||||
@ -22,3 +24,23 @@ for ($i = $start; $i < $end; $i++) {
|
||||
$manager->collectData($sites[--$i]);
|
||||
}
|
||||
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);
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
<?php
|
||||
use SvedenParser\ContingentParser\ContingentFacade;
|
||||
use SvedenParser\ContingentParser\ContingentManager;
|
||||
|
||||
require_once __DIR__ . "/vendor/autoload.php";
|
||||
|
||||
function getErrorSites($file)
|
||||
{
|
||||
$result = array();
|
||||
$data = file($file);
|
||||
foreach ($data as $value) {
|
||||
$value = explode(' ', $value);
|
||||
$result[] = $value[2];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function emptySites($sourceAll, $remains) {
|
||||
$result = array();
|
||||
foreach ($sourceAll as $every) {
|
||||
if (in_array($every['org_id'], $remains)
|
||||
&& $every['site'] === ''
|
||||
) {
|
||||
$result[] = $every['org_id'];
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function write($file, $source)
|
||||
{
|
||||
global $sourceAll;
|
||||
foreach($sourceAll as $s) {
|
||||
if (in_array($s['org_id'], $source)) {
|
||||
file_put_contents($file, implode(' ', $s).PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$facade = new ContingentManager();
|
||||
$sourceAll = $facade->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);
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user