News:

SMF 2.1.6 has been released! Take it for a spin! Read more.

Main Menu

Counts are wrong

Started by jrstark, April 03, 2007, 10:42:58 PM

Previous topic - Next topic

jrstark

I moved my forum from one host to another.  The domain is still on the old host, I have a frameset on the forum.  This is causing cookie issues for some people, I've given them the direct (nonframed) URL for now, I'm planning on moving the dns next week.  Any other suggestions for until then?

Another issue just came up.  At least one post count is off.  The poster has 54 posts, and they are still there if you look at his recent posts from his profile.  But when he posts, it says 25 posts and he's back to being a newbie.

I've run the maintenance links in the admin center, told it to recount totals a couple times as well.  It still isn't giving an accurate count.

metallica48423

#1
are there posts of his within boards that do not count posts toward the post count (if you click the modify link in Admin -> Boards then you can check that...

Otherwise, take a database backup, then try saving this as a file with a .php extention and run it... this code was written by one of the developers to recount post counts.


<?php
// Load SSI.php
require_once('SSI.php');

// Turn this on.
error_reporting(E_ALL);

// Are we allowed in here?
isAllowedTo('admin_forum');

$_REQUEST['start'] = !isset($_REQUEST['start']) ? '0' : (int) $_REQUEST['start'];

// Give a link to start
echo '
<h2><a href="'
, $_SERVER['PHP_SELF'], '?recount;start=0">Start Post Recount</a></h2>';

// Are we set to start?
if (isset($_REQUEST['recount']))
{
// Only run this query if we don't have the total.
if (!isset($_SESSION['totalMembers']))
{
$request = db_query("
SELECT COUNT(DISTINCT m.ID_MEMBER)
FROM (
{$db_prefix}messages AS m, {$db_prefix}boards AS b)
WHERE m.ID_MEMBER != 0
AND b.countPosts = 0
AND m.ID_BOARD = b.ID_BOARD"
, __FILE__, __LINE__);
list ($_SESSION['totalMembers']) = mysql_fetch_row($request);
mysql_free_result($request);
$_SESSION['recountedMembers'] = 0;
}

// Lets get the members and their post counts.
// Make sure that we only get boards that have posts count enabled.
// !!! On a big board 200 might be a bit to high to count.
$request = db_query("
SELECT m.ID_MEMBER, COUNT(m.ID_MEMBER) AS posts
FROM (
{$db_prefix}messages AS m, {$db_prefix}boards AS b)
WHERE m.ID_MEMBER != 0
AND b.countPosts = 0
AND m.ID_BOARD = b.ID_BOARD
GROUP BY m.ID_MEMBER
LIMIT
$_REQUEST[start], 200", __FILE__, __LINE__);
$_SESSION['recountedMembers'] += mysql_num_rows($request);

// Get all the results and assign the correct value.
while ($row = mysql_fetch_assoc($request))
db_query("
UPDATE
{$db_prefix}members
SET posts =
$row[posts]
WHERE ID_MEMBER =
$row[ID_MEMBER]", __FILE__, __LINE__);

// How many members have their post count been fixed?
echo '
<h3>'
, $_SESSION['recountedMembers'] >= $_SESSION['totalMembers'] ? $_SESSION['totalMembers'] : $_SESSION['recountedMembers'], '/', $_SESSION['totalMembers'], ' had their post count updated<h3>';

if ($_SESSION['recountedMembers'] >= $_SESSION['totalMembers'])
{
unset($_SESSION['recountedMembers'],$_SESSION['totalMembers']);
echo '
<h3>Done</h3>'
;
}
elseif ($_SESSION['recountedMembers'] < $_SESSION['totalMembers'])
echo '
<h3><a href="'
, $_SERVER['PHP_SELF'], '?recount;start=', $_SESSION['recountedMembers'], '">Next set of members</a></h3>';

}
?>
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

jrstark

All his posts are in one forum, none have been deleted.  I only have one forum that doesn't count.

I copied and saved it, uploaded it to /smf/ and ran it.  It said:

Start Post Recount
600/977 had their post count updated
Next set of members

Clicking on Next set doesn't do anything.  According to both the old and new forums, I have 1130 members.

Original poster is still missing posts, also someone else said his numbers dropped too.

metallica48423

I just ran this script without error on another site.  The number of members also varies, one set of numbers counts unactivated members, the other does not.  In any case,  the script recounts posts based on the settings for boards not counting posts, so its possible that any older posts that he DID get credit for before the board was switched to not count were recounted, does his new post count reflect how many posts are actually showing if you go to his profile and click 'view posts'?
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

jrstark

It worked now!

The number showing under his name (26) was the same as on his profile page.  But when you looked at the actual posts, he had 56.  This is a fairly new poster, all but three posts from this year.

Well, all his posts are showing, but he's still listed as newbie.  Over 50 posts should be Jr. Member.

metallica48423

did he make 30 posts in a non counting board or something?  you're saying 26 and 56 and just totally confused me :P
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

jrstark

He has 56 posts in one board that is counted.  After the move, it was showing 26 posts under his name on posts and on the profile page.  But when you clicked on "recent posts" it showed all 56 posts, which are all in the same forum.

After the second time I ran the code given above, it now shows 56 posts under his name.  But it is still listing him as "Newbie" and not "Jr. Member" even though he again is getting credit for all his posts, and the breakpoint between Newbie and Jr. Member is 50 posts.


metallica48423

run the recount totals and statistics, or have him post, and it should update it.  That script doesn't handle that, strictly post counts.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

marduk420

i would just like to say that i was having this exact same problem.  one of our user's had his post count saying 8669 when our board only had around 2000 posts.  i ran the script in above in the root directory and it worked like a charm :)  thx!

Advertisement: