Please upgrade here. These earlier versions are no longer being updated and have security issues.

How to show users' discussions count through Vanilla Statistics dashboard.

ProsperProsper ✭✭
edited June 2016 in Vanilla 2.0 - 2.3

How can users' discussions count through Vanilla Statistics be shown on the dashboard just like the users' comment count?
I have tried adding <td><?php echo number_format($User->CountComments); ?></td> but erroneously showed discussion counts to be zeros.

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Where did you try adding this?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight
    Sorry for my mistake, the correct code I tried adding is <td><?php echo number_format($User->CountDiscussions); ?></td> on /plugins/VanillaStats/views/dashboardsummaries.php but got all zeros users' discussion counts on the dashboard.

  • RiverRiver MVP
    edited June 2016

    @Prosper said:
    @hgtonight
    Sorry for my mistake, the correct code I tried adding is <td><?php echo number_format($User->CountDiscussions); ?></td> on /plugins/VanillaStats/views/dashboardsummaries.php but got all zeros users' discussion counts on the dashboard.

    Probably not a good idea to change staff plugins that come with core, unless they are broken.

    but you need to know a few things. you can't show data that you don't have. You need to retrieve it first if you want to show it.

    I haven't tested nor do I suggest you do it, but it couldn't possibly work what you want if the data is not retrieved first and handed to the view. .

    see this UserData is set here.

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/VanillaStats/class.vanillastats.plugin.php#L181

     // Load the most active users during this date range
    $Sender->setData('UserData', $UserModel->SQL
    ->select('u.UserID, u.Name')
    ->select('c.CommentID', 'count', 'CountComments')
    ->from('User u')
    ->join('Comment c', 'u.UserID = c.InsertUserID', 'inner')
    ->groupBy('u.UserID, u.Name')
    ->where('c.DateInserted >=', $Sender->DateStart)
    ->where('c.DateInserted <=', $Sender->DateEnd)
    ->orderBy('CountComments', 'desc')
    ->limit(10, 0)
    ->get());
    

    notice there is not a CountDiscussions selected from the User table above. if you want it you need to select it in the setData. change the ->select('u.UserID, u.Name') to include what ever user column you want in the class.vanillastats.plugin.php

    so it can be read here in the summaries

    notice the for each for the userdata here:

    https://github.com/vanilla/vanilla/blob/Vanilla_2.2.1/plugins/VanillaStats/views/dashboardsummaries.php#L35

     <?php foreach ($this->Data['UserData'] as $User) { ?>
    <tr>
    <th><?php echo anchor($User->Name, 'profile/'.$User->UserID.'/'.Gdn_Format::url($User->Name)); ?></th>
    <td><?php echo number_format($User->CountComments); ?></td>
    <!-- <td><?php // echo number_format($Discussion->CountViews); ?></td> -->
    </tr>
    <?php } ?>
    

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

    vrijvlinder
  • @River - thank you for your comment. I am not exactly a developer. What code should I modify, remove or add to achieve my aim of showing the discussions statistic for each user on the dashboard? Can a new plugin do it?

  • RiverRiver MVP
    edited June 2016

    @River - thank you for your comment. I am not exactly a developer. What code should I modify, remove or add to achieve my aim of showing the discussions statistic for each user on the dashboard? Can a new plugin do it?

    I was hesitant to answer you in the post, because you would get the wrong impression, that I was going to solve your problem. I was basically just showing you how it could not possibly work just with your change. You would need to think out the logic, if you want something based on user discussion count for a specific time period. if you just want total Discussion count for a user you can use an existing plugin. If you just care about total Discussion count for a user you can pull it from User Table.

    The logic for selecting probably needs to come from the Discussion table if you are selecting based on a time period.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

    vrijvlinder
  • ProsperProsper ✭✭
    edited June 2016

    @River - I want to select discussion counts for each user based on a time period not total discussion just like the comments are selected based on time period on the bashboard. Thanks for you comments anyway.

  • hgtonighthgtonight ∞ · New Moderator

    @Prosper said:
    @River - I want to select discussion counts for each user based on a time period not total discussion just like the comments are selected based on time period on the bashboard. Thanks for you comments anyway.

    That graph is generated by Vanilla Inc.'s servers. You can still modify it, but it would take a lot of effort and reverse engineering.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @hgtonight - how about a new plugin that can generate discussion and comment counts for users based on selected time period?

  • hgtonighthgtonight ∞ · New Moderator

    @Prosper said:
    @hgtonight - how about a new plugin that can generate discussion and comment counts for users based on selected time period?

    Sounds like a great idea; I can't wait to see it :)

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    R_J
  • @hgtonight said:

    @Prosper said:
    @hgtonight - how about a new plugin that can generate discussion and comment counts for users based on selected time period?

    Sounds like a great idea; I can't wait to see it :)

    Yes it is a great idea. Unfortunately, I am not a developer. Please can someone work on this plugin?

  • hgtonighthgtonight ∞ · New Moderator
    edited June 2016

    @Prosper We'll be here if you need help. :)

    @River said:

    You have just been given permission to enrich your mind. Never say no, and don't say you can't do it. put your mind to it and prosper.

    This is a great sentiment.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.