In Reply To:
I would wish to rebuild the base of data once per day automatiquely, and delete de "votes".
In Reply To:
Example: when I rebuild the base of data on June 25, I would like that it calculation the number of votes, hits, according to the data of June 24 or if possible last 24 hours.
I think part of it would be fairly easy. Just as long as you don't care that the previous votes and rating get deleted each day.
In
nph-build.cgi find sub
build_update_ratings { at around line 423.
Find the part in the subroutine (around line 449) with:
Code:
$id = $values[0];
if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
($values[$db_votes] + $votes{$id});
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
$values[$db_votes] = $values[$db_votes] + $votes{$id};
print "\tUpdating rating to $values[$db_rating] for link id $id\n";
}
print DBTMP &join_encode(&array_to_hash(0, @values));
}
close DB;
close DBTMP;
Try changing it to:
Code:
$id = $values[0];
$values[$db_rating] = 0; # Reset Rating to zero $values[$db_votes] = 0; # Reset Votes to zero if (exists $votes{$id}) {
$values[$db_rating] = (($values[$db_rating] * $values[$db_votes]) + $rating{$id}) /
($values[$db_votes] + $votes{$id});
$values[$db_rating] = sprintf ("%.2f", $values[$db_rating]);
$values[$db_votes] = $values[$db_votes] + $votes{$id};
print "\tUpdating rating to $values[$db_rating] for link id $id\n";
print DBTMP &join_encode(&array_to_hash(0, @values)); } else { print DBTMP &join_encode(&array_to_hash(0, @values));
} }
close DB;
close DBTMP;
This is untested! Be sure to make a backup of your links.db file just in case.
This should reset all the Rating and Votes to zero each time nph-build is run, then add the last days Rating and Votes to the database. After that it should calculate the ratings based on only the new rating since the last build.
This does not effect the What's Popular/Cool pages as it does nothing with the Hits field at all. If you also want that, it pobably has to be done in the sub build_update_newpop but I didn't look very hard. Try the other first and
Be sure to make a backup of your links.db file just in case. Dan O.