Execution du ciblage
This commit is contained in:
parent
3eabd646fc
commit
d361a0feb0
@ -168,43 +168,47 @@ class Scores_Ciblage_Engine
|
||||
$siret[] = $element['attrs']['siren'].$element['attrs']['nic'];
|
||||
}
|
||||
return $siret;
|
||||
} else
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Execute le ciblage
|
||||
* @param boolean $need
|
||||
* Si true retourne les identifiants
|
||||
* @param int $nbReturn
|
||||
*
|
||||
*/
|
||||
public function execute($need = false, $nbReturn = 0)
|
||||
{
|
||||
// --- Active le filtre RNCS sur le profil du client
|
||||
if ($this->filterRNCS==1) {
|
||||
$this->sphinx->SetFilter('presentrcs', array(1));
|
||||
}
|
||||
|
||||
// --- Retourne les identifiants
|
||||
if( $need ) {
|
||||
$return = array();
|
||||
$limit = 1000;
|
||||
$maxMatches = 50000;
|
||||
|
||||
// --- Set basic limit
|
||||
if ( $nbReturn > 0 ) {
|
||||
$limit = $nbReturn;
|
||||
$maxMatches = $nbReturn;
|
||||
$this->sphinx->SetSortMode( SPH_SORT_EXTENDED, '@random' );
|
||||
}
|
||||
|
||||
// --- Replay the query
|
||||
$this->sphinx->SetLimits(0, $limit, $maxMatches);
|
||||
$resSphinx = $this->sphinx->Query($this->alpha, $this->index);
|
||||
|
||||
//Make an array with only the data needed
|
||||
$return = $this->getSiret($resSphinx);
|
||||
|
||||
$total = $resSphinx['total_found'];
|
||||
|
||||
if ( $nbReturn == 0 && $limit<$total ) {
|
||||
// --- Make an array with only the data needed
|
||||
$return = $this->getSiret($resSphinx);
|
||||
|
||||
if ( $total > $limit ) {
|
||||
$max = ceil($total/$limit);
|
||||
//Get siret by $limit units for each request
|
||||
for($i=1; $i<$max; $i++) {
|
||||
$offset = $i*$limit;
|
||||
$this->sphinx->SetLimits($offset, $limit);
|
||||
@ -215,8 +219,10 @@ class Scores_Ciblage_Engine
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
} else {
|
||||
// --- Retourne seulement le nombre total
|
||||
else {
|
||||
|
||||
$this->sphinx->SetLimits(0, 1);
|
||||
Zend_Registry::get('firebug')->info("Sphinx : ".$this->alpha);
|
||||
|
Loading…
Reference in New Issue
Block a user