WordPress.org

Ready to get started?Download WordPress

Forums

amr users
Inaccurate Comments Count (7 posts)

  1. Swampy
    Member
    Posted 7 months ago #

    I understand (I think) the caveats overview in the link provided from the plugin, i.e. http://wpusersplugin.com/1822/comment-totals-by-authors/.

    I have a fairly simple site, with three users who have provided comments (and replies). The total number is 97 in the Comments area (not sure how many of these are 'replies'. Akismet reporting shows 39, 38, and 20 "approved" items for Users 1 - 3, so that aligns.

    As well, WP Stats page (under the dashboard tab) shows:
    User 1(39)
    User 2(38)
    User 3(20)

    So that ties with total and Akismet.

    I set-up a report reporting both Comments count and Replies count and got the following (comments / replies):

    User 1 29 / 3
    User 2 38 / 2
    User 3 20 / 3

    First item is a question, does the comments count (essentially) include replies?

    Presuming the answer to this is 'Yes", then users 2 and 3 have counts that align. However User 1 is showing 10 fewer than he should.

    Any thoughts on what might be causeing this reconciliation problem or how I might debug this?

    https://wordpress.org/plugins/amr-users/

  2. Swampy
    Member
    Posted 7 months ago #

    Sorry, follow-up on my own post. Clearly Comments and Replies are different data types, and I now see that the Reply count (for each of three users) matches up. Hence, only issue is that the Comments Count for User 1 is off by 10.

  3. anmari
    Member
    Plugin Author

    Posted 7 months ago #

    Hi - had a quick look and one reason might be :
    amr-users queries comments made by users (not by non-users) AND if an email address first made comments as a non-user than became a user, WP does NOT go back and update it's comment history. (It stores userid in the comments table).

    So amr-users will NOT include comments without a userid (ie userid=0) and will include comments even if to a post that no longer exists and/or has changed status. (Looking at user activity)

    wp-stats queries and groups by email (doesn't care about userid).

    There are also other differences - wpstats is 'post oriented', so if a post changes status this might also cause a difference. where wp-stats might exclude those comments.

    See:

    amr-users:

    SELECT user_id, comment_author_email, count(1) as \"comment_count\" FROM $wpdb->comments WHERE $approved AND user_id > 0 GROUP BY user_id, comment_author_email;

    wpstats:

    `SELECT comment_author, COUNT(comment_ID) AS 'comment_total' FROM $wpdb->comments INNER JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_approved = '1' AND comment_type = '' "
    ."AND post_date < '".current_time('mysql')."' "
    ."AND post_status = 'publish' AND post_password = '' GROUP BY comment_author ORDER BY comment_total DESC $limit_sql")`

  4. Swampy
    Member
    Posted 7 months ago #

    Anmari, many thanks for this guidance. Useful possibilities. I've just (sort of accidentally) hit on a lead to sorting this out / understanding what might be going on -- perhaps need to directly clean some things up in database, though concerned about this behavior going forward for other users . . . so here's what I've figured out since my first post.

    This particular user changed his email in the course of matters, from a .org extension to a .com extension.

    He's written 39 total comments, they are all showing as User ID = 10, the most recent 10 of which are showing his email as .com, and these are (apparently) not being counted. If I simply go to comment (and remember they are all User ID = 10, not 0s) and change email address for author of comment (back) to the .org, this then shows up in the count. So there definitely seems to be some linkage.

    It seems like some focus / use of the email address needing to match some sort of 'original email' address sitting in the comments table for purposes of this counting (or it uses the first / earliest comment to instance of email address)?

    Is that consistent with behavior you might expect and/or is there something in this that should be amended perhaps in the code? I'm not a PHP guy, but is the second argument in the GROUP BY statement, by comment_author_email appropriate? Shouldn't we simply be getting counts for a given user_ID, which should be unique, not a 'shared persona', if that makes sense?

  5. Swampy
    Member
    Posted 7 months ago #

    Just as a test / follow-up, I hacked out the second argument of the GROUP BY element, so just groups by User ID, and this seems to fix count problem (in my case) -- on first blush, not tested much yet. Curious as to rationale for the secondary grouping and where I'm likely to hit problems with that hack.

    John

    P.S. btw, I'm completely clueless on WordPress, PHP, etc (set up my first website about 8 weeks ago), but how in God's name to you developers set yourself up to find code strings across multiple files -- I mean brutal (for me) in this instance to find that your quoted statement was in your ameta-list.php file. How do you guys do this properly -- I can't seem to find any plugins for 'search across multiple files' in the Admin area.

  6. anmari
    Member
    Plugin Author

    Posted 7 months ago #

    you may have a point re just using userid.

    re working tools:
    always always always run a local server (working remotely is difficult) - see WAMP
    and use notepad++ on windows (there are others for mac but notepad++ is best)

  7. Swampy
    Member
    Posted 7 months ago #

    many thanks for that. I'll advise re: I see any issues that might be connected to my hack of that one statement. Perhaps rationale was to sub-deivide the UserID = 0 entries by email address? Not sure if there would be one, though, for unregistered users. If the case, perhaps a conditional on this one circumstance -- God knows.

    Excellent support and excellent plugin. Very helpful in upgrading user management short of moving to a CRM system, which can be a bit overblown for some purposes.

Reply

You must log in to post.

About this Plugin

About this Topic