tags:

views:

72

answers:

5

Many forums have a feature that shows posts per day for a given user.

How do they calculate that number?

A: 

I'm not sure what you're asking. They have in their database a complete lists of posts, who posted them, and when the poster registered, so it's just division. Someone who registered 3 days ago and has 12 posts has posted 4 times/day

Michael Mrozek
+1  A: 

The posts are stored in a database, with a timestamp. Just as on this forum. Then it simply becomes a trivial SQL query (or it is placed in the business logic layer) to find the posts on a particular day.

SELECT Count(*) As Total FROM tblPosts 
    INNER JOIN tblUsers ON tlbPosts.UserId = tblUsers.UserId
    WHERE PostDate > tblUsers.RegistrationDate AND PostDate < Today

The result should be divided by the number of days in the period you want the average of.

Abel
I don't think this is what he wants. He's looking for an average post count over time.
Matti Virkkunen
Isn't that what I answered (sorry, was quick edit meanwhile). Too simplistic (@Downvoters)?
Abel
A: 

Forums mostly record posts along with date in one row, of course there are user information too. Then the information about all posts is compared with user registration date and depending on results you get your answer.

Well, actually not sure if many forums use that, but I have used this before and some easy forums have same solution. (Since it's long since I've used phpBB or any other free well-built forums, I cannot give you a perfect match!)

Tom
+1  A: 
<?php
// test data
$registerDate = strtotime("2010-03-01");
$totalPosts = 500;

// calculation
$days = round((time() - $registerDate) / 86400);
$postsPerDay = round($totalPosts / $days);

// output
echo "Posts per day: " . $postsPerDay;
?>
codescape
+1  A: 

Number of posts divided by the number of days the user has been a member?

John at CashCommons