Finished function to compute forum activity values and store them in the database.

svn path=/trunk/boinc/; revision=1874
This commit is contained in:
David Anderson 2003-07-30 20:06:18 +00:00
parent 23f491368b
commit 4eb9398e73
1 changed files with 21 additions and 2 deletions

View File

@ -2,11 +2,30 @@
<?php
require_once("../html_user/db.inc");
require_once("../html_user/forum/forum.inc");
require_once("../html_user/util.inc");
define('MAX_REWARD', 4096);
db_init();
// TODO: Update activity fields for all threads here.
$currentTime = time();
$result = mysql_query("SELECT * FROM thread");
while ($thread = mysql_fetch_assoc($result)) {
$sql = "SELECT * FROM post WHERE thread = " . $thread['id'];
$result2 = mysql_query($sql);
$points = 0;
while ($post = mysql_fetch_assoc($result2)) {
$timeDiff = $currentTime - $post['timestamp'];
$dayDiff = floor($timeDiff / 86400); // 86400 = # of seconds in a day;
$points += (MAX_REWARD / pow(2, $dayDiff));
}
$sql = "UPDATE thread SET activity = " . ceil($points) . " WHERE id = " . $thread['id'];
mysql_query($sql);
}