Commit eff3c991 authored by Feu's avatar Feu

des constantes c'est mieu

parent 3e8fc3fd
......@@ -151,9 +151,9 @@ if ( $_REQUEST["action"] == "info" )
list($nbphotos) = $req->get_row();
$total += $nbphotos;
$total += round($nbphotos/GALAXY_SCORE_1PTPHOTO);
$reasons->add("$nbphotos photos ensemble : $nbphotos points");
$reasons->add("$nbphotos photos ensemble : ".round($nbphotos/GALAXY_SCORE_1PTPHOTO)." points");
$req = new requete($site->db, "SELECT COUNT(*) ".
"FROM `parrains` ".
......@@ -162,9 +162,9 @@ if ( $_REQUEST["action"] == "info" )
list($nbpar) = $req->get_row();
$total += $nbpar*15;
$total += $nbpar*GALAXY_SCORE_PARRAINAGE;
$reasons->add("$nbpar lien de parrainage : ".($nbpar*15)." points");
$reasons->add("$nbpar lien de parrainage : ".($nbpar*GALAXY_SCORE_PARRAINAGE)." points");
$req = new requete($site->db,"SELECT asso.nom_asso, a.id_asso,
SUM(DATEDIFF(LEAST(COALESCE(a.date_fin,NOW()),COALESCE(b.date_fin,NOW())),GREATEST(a.date_debut,b.date_debut))) AS together
......@@ -173,7 +173,7 @@ if ( $_REQUEST["action"] == "info" )
(
b.id_utilisateur='".intval($user_b->id)."'
AND a.id_asso = b.id_asso
AND DATEDIFF(LEAST(COALESCE(a.date_fin,NOW()),COALESCE(b.date_fin,NOW())),GREATEST(a.date_debut,b.date_debut)) > 74
AND DATEDIFF(LEAST(COALESCE(a.date_fin,NOW()),COALESCE(b.date_fin,NOW())),GREATEST(a.date_debut,b.date_debut)) >= ".GALAXY_SCORE_1PTJOURSASSO."
)
INNER JOIN asso ON (asso.id_asso = a.id_asso)
WHERE a.id_utilisateur='".intval($user_a->id)."'
......@@ -181,12 +181,15 @@ if ( $_REQUEST["action"] == "info" )
while ( $row = $req->get_row() )
{
$reasons->add($row["together"]." jours ensemble à ".$row["nom_asso"]." : ".round($row["together"]/75,3)." points");
$total += $row["together"]/75;
$reasons->add($row["together"]." jours ensemble à ".$row["nom_asso"]." : ".round($row["together"]/GALAXY_SCORE_1PTJOURSASSO,3)." points");
$total += $row["together"]/GALAXY_SCORE_1PTJOURSASSO;
}
$reasons->add("<b>Total: ".round($total)." points</b>");
if ( round($total) < GALAXY_MINSCORE )
$reasons->add("<i>Score trop faible pour le lien puisse être considéré comme pertinent</i>");
$cts->add($reasons);
$cts->add_title(2,"A propos de galaxy");
......
......@@ -25,6 +25,10 @@
* 02111-1307, USA.
*/
define("GALAXY_SCORE_1PTPHOTO",1);
define("GALAXY_SCORE_PARRAINAGE",15);
define("GALAXY_SCORE_1PTJOURSASSO",75);
define("GALAXY_MINSCORE",10);
class galaxy
{
......@@ -62,7 +66,7 @@ class galaxy
// 1- Cacul du score
// a- Les photos : 1pt / photo ensemble
// a- Les photos : 1pt / n photo ensemble
$req = new requete($this->db, "SELECT COUNT( * ) as c, p1.id_utilisateur as u1, p2.id_utilisateur as u2 ".
"FROM `sas_personnes_photos` AS `p1` ".
"JOIN `sas_personnes_photos` AS `p2` ON ( p1.id_photo = p2.id_photo ".
......@@ -74,10 +78,10 @@ class galaxy
$a = min($row['u1'],$row['u2']);
$b = max($row['u1'],$row['u2']);
$liens[$a][$b] = $row['c'];
$liens[$a][$b] = round($row['c']/GALAXY_SCORE_1PTPHOTO);
}
// b- Parrainage : 15pt / relation parrain-fillot
// b- Parrainage : n pt / relation parrain-fillot
$req = new requete($this->db, "SELECT id_utilisateur as u1, id_utilisateur_fillot as u2 ".
"FROM `parrains` ".
"GROUP BY id_utilisateur, id_utilisateur_fillot");
......@@ -87,12 +91,12 @@ class galaxy
$b = max($row['u1'],$row['u2']);
if ( isset($liens[$a][$b]) )
$liens[$a][$b] += 15;
$liens[$a][$b] += GALAXY_SCORE_PARRAINAGE;
else
$liens[$a][$b] = 15;
$liens[$a][$b] = GALAXY_SCORE_PARRAINAGE;
}
// c- associations et clubs : 1pt / 75 jours ensemble / assos
// c- associations et clubs : 1pt / n jours ensemble / assos
$req = new requete($this->db,"SELECT a.id_utilisateur as u1,b.id_utilisateur as u2,
SUM(DATEDIFF(LEAST(COALESCE(a.date_fin,NOW()),COALESCE(b.date_fin,NOW())),GREATEST(a.date_debut,b.date_debut))) AS together
FROM asso_membre AS a
......@@ -100,7 +104,7 @@ class galaxy
(
a.id_utilisateur < b.id_utilisateur
AND a.id_asso = b.id_asso
AND DATEDIFF(LEAST(COALESCE(a.date_fin,NOW()),COALESCE(b.date_fin,NOW())),GREATEST(a.date_debut,b.date_debut)) > 74
AND DATEDIFF(LEAST(COALESCE(a.date_fin,NOW()),COALESCE(b.date_fin,NOW())),GREATEST(a.date_debut,b.date_debut)) >= ".GALAXY_SCORE_1PTJOURSASSO."
)
GROUP BY a.id_utilisateur,b.id_utilisateur
ORDER BY a.id_utilisateur,b.id_utilisateur");
......@@ -111,16 +115,16 @@ class galaxy
$b = max($row['u1'],$row['u2']);
if ( isset($liens[$a][$b]) )
$liens[$a][$b] += round($row['together']/75);
$liens[$a][$b] += round($row['together']/GALAXY_SCORE_1PTJOURSASSO);
else
$liens[$a][$b] += round($row['together']/75);
$liens[$a][$b] = round($row['together']/GALAXY_SCORE_1PTJOURSASSO);
}
// 2- On vire les liens pas significatifs
foreach ( $liens as $a => $data )
{
foreach ( $data as $b => $score )
if ( $score < 10 )
if ( $score < GALAXY_MINSCORE )
unset($liens[$a][$b]);
}
......
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