Commit 8e8ef577 authored by Raphael's avatar Raphael
Browse files

Ajout de batch pour le refactor

parent 9813a2aa
......@@ -1337,5 +1337,138 @@ class DatamigrationController extends CommunecterController {
echo "NB Element mis à jours: " .$nbelement."<br>" ;
}
public function actionPays(){
$phCountries = array(
//"BE"=>"Belgique",
//"FR"=>"France",
//"GP"=>"Guadeloupe", //971
"GF"=>"Guyanne Française", //973
//"MQ"=>"Martinique", //972
//"YT"=>"Mayotte", //976
"NC"=>"Nouvelle-Calédonie", //988
//"RE"=>"Réunion", //9*74
"PM"=>"St Pierre et Miquelon"
);
foreach ($phCountries as $keyElt => $pays) {
$zone = Zone::createLevel($pays, "FR", "1", null);
if(!empty($zone)){
//var_dump($zone["name"]);
Zone::save($zone);
}
}
}
public function actionDom(){
$phCountries = array(
/*"France",
"Guadeloupe", //971*/
"French Guiana", //973
/*"Martinique", //972
"Mayotte", //976*/
//"Nouvelle-Calédonie", //988
//"Réunion", //9*74
"Saint Pierre et Miquelon"
);
foreach ($phCountries as $keyElt => $pays) {
var_dump($pays);
$zone = Zone::createLevel($pays, "FR", "1", null);
if(!empty($zone)){
Zone::save($zone);
}
}
}
public function actionDepRefactorCitiesZones(){
ini_set('memory_limit', '-1');
$nbelement = 0 ;
$dep = array();
$cities = PHDB::find(City::COLLECTION, array("depName" => array('$exists' => 1)));
if(!empty($cities)){
foreach (@$cities as $keyElt => $city) {
if(!empty($city["depName"]) && trim($city["depName"]) != "" && !in_array($city["depName"], $dep)){
$dep[] = $city["depName"];
$zone = Zone::createLevel($city["depName"], $city["country"], "4");
if(!empty($zone)){
$nbelement++;
Zone::save($zone);
}
}
}
}
echo "NB Element mis à jours: " .$nbelement."<br>" ;
}
public function actionRegionBERefactorCitiesZones(){
ini_set('memory_limit', '-1');
$nbelement = 0 ;
$region = array();
$cities = PHDB::find(City::COLLECTION, array("regionNameBel" => array('$exists' => 1)));
if(!empty($cities)){
foreach (@$cities as $keyElt => $city) {
if(!empty($city["regionNameBel"]) && trim($city["regionNameBel"]) != "" && !in_array($city["regionNameBel"], $region)){
$zone = Zone::createLevel($city["regionNameBel"], $city["country"], "2");
if(!empty($zone)){
$region[] = $city["regionNameBel"];
$nbelement++;
Zone::save($zone);
}else{
echo "Erreur: " .$city["regionNameBel"]." : City :".(String)$city["_id"]."<br>" ;
}
}
}
}
foreach (@$region as $k => $v) {
echo "Good: " .$v."<br>" ;
}
echo "NB Element mis à jours: " .$nbelement."<br>" ;
}
public function actionRegionRefactorCitiesZones(){
ini_set('memory_limit', '-1');
$nbelement = 0 ;
$region = array();
$cities = PHDB::find(City::COLLECTION, array("regionName" => array('$exists' => 1)));
if(!empty($cities)){
foreach (@$cities as $keyElt => $city) {
if(!empty($city["regionName"]) && trim($city["regionName"]) != "" && !in_array($city["regionName"], $region)){
$zone = Zone::createLevel($city["regionName"], $city["country"], "3");
if(!empty($zone)){
$region[] = $city["regionName"];
$nbelement++;
//Zone::save($zone);
}else{
$erreur[(String)$city["_id"]] = $city["regionName"];
//echo "Erreur: " .$city["regionName"]." : City :".(String)$city["_id"]."<br>" ;
}
}
}
}
foreach (@$region as $k => $v) {
echo "Good: " .$v."<br>" ;
}
foreach (@$erreur as $k => $v) {
echo "Erreur: " .$v." : City :".$k."<br>" ;
}
echo "NB Element mis à jours: " .$nbelement."<br>" ;
}
public function actionTest2(){
$test = Zone::getIdCountryByCountryCode("FR") ;
var_dump($test);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment