Gossamer Forum
Home : Products : Links 2.0 : Customization :

automatic delete votes

Quote Reply
automatic delete votes
Hello,

I would wish to rebuild the base of data once per day automatiquely, and delete de "votes". Thus the classification will be made once per day according to the results of the day before.
How then-to make?

Laurent


Quote Reply
Re: automatic delete votes In reply to
This would be a bit difficult...but as a starting point, you should search this forum Reset Hits...there is a Thread that includes a script to reset hits, which can be applied to reseting votes...Also, Widgetz's Review.cgi as a script called reset.cgi which deletes votes and ratings.

Regards,

Eliot Lee
Quote Reply
Re: automatic delete votes In reply to
Thank you Eliot

I would wish that " links 2.0 " calculate the number of votes according to the average of the day before. And that is reflected on the top 10, the top 10 on my Home Page and on all the links. I would like a modification general of the calculation mode of the votes.
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 would thus wish to change the mathematical formula which calculates the number of vote of the sites in the nph-build.cgi according to the dates.

This is possible and especially somebody can it help me. I am null in Perl, but I need really this " MOD ".

thank you with all and Eliot

Laurent



Quote Reply
Re: automatic delete votes In reply to
If all you want is to have votes by days...Bobsie has provided codes for this before in this forum and he has this option working in his web site.

Regards,

Eliot Lee
Quote Reply
Re: automatic delete votes In reply to
hello,

Thank you.

I'm not very good in perl...
How Can I make to change the mod of bobsie for "votes" ?

Laurent,

Thank you

Quote Reply
Re: automatic delete votes In reply to
I must make a modif this ?
$values[$db_votes] = $values[$db_votes] + $votes{$id};

in the
sub build_update_ratings {
# --------------------------------------------------------
# Updates the ratings of each link.

Quote Reply
Re: automatic delete votes In reply to
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.