Right, I'd seen that bit of the code, but not the BoincUser:ercentile part, so wasn't sure of that was doing something different.
Good point that he may have taken away the delete, it looks horribly inefficient they way it's coded anyway going through everyone, but if they do that then without an export of the badges there would be no way for me to figure them out with the data in my tables and I hate scraping pages...
mine is a little easier, though I was a little lazy on some parts of it, like using the fetchrow_array on a single column, but wth..
Code:
sub pctbadges {
($proj, $subproj, $pct, $pct2,$badge) = @_;
print "proj is $proj, lowerbound is $lowerbound, upperbound is $upperbound, badge is $badge...\n";
$sql = "select (count(*) * $pct/100) + 0.5 from dcfree.boinc_user where proj = '$proj' and metric2 > 1";
$query = $dbh->prepare($sql);
$query->execute;
$racpercentile1 = $query->fetchrow_array;
print "racpercentile = $racpercentile1, subproj is $subproj\n";
$sql = "select (count(*) * $pct2/100) + 0.5 from dcfree.boinc_user where proj = '$proj' and metric2 > 1";
$query = $dbh->prepare($sql);
$query->execute;
$racpercentile2 = $query->fetchrow_array;
print "racpercentile = $racpercentile2, subproj is $subproj\n";
$query->finish;
$sql = "delete from static.boinc_badges where proj = '$proj' and subproj='$subproj'";
$query = $dbh->prepare($sql);
$query->execute;
$query->finish;
$sql = "insert into static.boinc_badges (select '$proj','$subproj',id,cpid,'$badge' from dcfree.boinc_user where proj = '$proj' and racrank0 < $racpercentile1 and racrank0 > $racpercentile2)";
$query = $dbh->prepare($sql);
$query->execute;
$query->finish;
}
It seems to work for your project though so the badges are displaying
Originally Posted by
Slicker
That's the source, but the MySQL table contains a field named "sql_rule" which I believe the project admin can override in order to change the way it awards badges. DA, of course, wants everyone that already has badges to change the his version. So far, no one has. Maybe it is because that with his scheme, you may have a badge one day but it can get taken away from you the next. That isn't right! If you earned it, it should be yours forever.
Anyway, collatz didn't change his code. My guess is that Convector did. Maybe they removed the code that clears the badges before re-assigning so that if you earned it at any time you get to keep it. I have considered doing that.