Skip to content

Commit

Permalink
Création d'un script pour geocoder toutes les candidatures en base (a…
Browse files Browse the repository at this point in the history
…dmin uniquement) #37
  • Loading branch information
oceanBigOne committed Mar 25, 2017
1 parent 9cd64d5 commit e9fcfd0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pages/admin/candidature/geocode-all.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

$oListeCandidature=new CandidatureListe();
$oListeCandidature->applyRules4ListAdmin();

$aCandidatures=$oListeCandidature->getPage();
$aObj=array();

ini_set('max_execution_time', count($aCandidatures)*3);

foreach($aCandidatures as $aCandidature){
$oCandidature=new Candidature(array("id"=>$aCandidature["id"]));
$oCandidature->hydrateFromBDD(array('*'));

$coordinate= $oCandidature->geocode();
if(!is_null($coordinate["lat"]) && !is_null($coordinate["lng"]) ) {
$oCandidature->setLat($coordinate["lat"]);
$oCandidature->setLng($coordinate["lng"]);
$oCandidature->save();
}
sleep(1);
array_push($aObj, $oCandidature);
}

$aDataScript["candidatures"]=$aObj;
5 changes: 5 additions & 0 deletions templates/admin/candidature/geocode-all.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% for candidature in candidatures %}

<div>#ID : {{ candidature.id }} : {{ candidature.city }},{{ candidature.zipcode }} : {{ candidature.lat }};{{ candidature.lng }} </div>

{% endfor %}

0 comments on commit e9fcfd0

Please sign in to comment.