1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unmaintained Top Contributors Leaderboard 1.1.3

Generates a monthly leaderboard of top contributors to the forum

  1. wdb

    wdb Active Member

    wdb submitted a new resource:

    Top Contributors Leaderboard (version 1.0) - Generates a monthly leaderboard of top contributors to the forum

    Read more about this resource...
     
    Garamond, Eagle, bellegend and 3 others like this.
  2. ArnyVee

    ArnyVee Well-Known Member

    Interesting .... could be used for a 'monthly contest' setup.

    Can you add the ability for a custom timeframe rather than just monthly? This would be perfect :)

    Thanks for sharing this. (y)
     
    Brandon Sheley likes this.
  3. HWS

    HWS Well-Known Member

    After looking at the code, I would not recommend installing this addon except you have a very, very small forum.

    Other forums will have a massive resource problem with the database calls this addon does at every single call of the leaderboard page.
     
  4. wdb

    wdb Active Member

    Yes it could be a bit of a hit on resources on a big database, working fine for me with 250k posts. That is why I added the usergroup permissions so you can prevent guests/bots from hammering the database.

    Can you suggest any better way the query could be handled ?
     
  5. ragtek

    ragtek Guest

    i hadn't checked the query, but you shouldn't run the code(query) for people without permission to view the page...

    Move the permission check to top and return a no perm error
    PHP:
    throw $this->getNoPermissionResponseException();
    if the visitor doesn't have permissions
     
  6. wdb

    wdb Active Member

    I don't think it does call the query for people without permission, the controller checks permission before calling the model. I'll try out your suggestion though as it looks like it may be more elegant than mine.
     
  7. ragtek

    ragtek Guest

    no

    you're running getTopUsers even the user doesn't have perms

    PHP:
    class TopUsers_ControllerPublic_Index extends XenForo_ControllerPublic_Abstract
    {
    public function 
    actionIndex()
    {
    $month_id $this->_input->filterSingle('month_id'XenForo_Input::UINT);
     
    $topUsers $this->_getTopUsersModel()->getTopUsers($month_id);
     
    $viewParams = array(
    'topUsers' => $topUsers
    );
     
    if (
    XenForo_Visitor::getInstance()->hasPermission('topUsers''canViewTopUsers')) 
    {
    return 
    $this->responseView('TopUsers_ViewPublic_Index''top_users_index'$viewParams);
    } else {
    return 
    $this->responseView('TopUsers_ViewPublic_Index''top_users_index', array('canView'=>0));
    }
    }
     
  8. bellegend

    bellegend Member

    good work
    if you plane to use this addon in forums with big database

    you can run the sql query one time per day
    PHP:
    $users $this->_getDb()->fetchAll('
                    SELECT *, count(*) messages_delta, sum(likes) likes_delta, count(*) + sum(likes) score_delta
                    FROM xf_post p JOIN xf_user u ON p.user_id=u.user_id JOIN xf_user_profile r on p.user_id=r.user_id
                    WHERE  post_date > ? AND post_date < ?
                    GROUP BY p.user_id
                    ORDER BY score_delta DESC
                    LIMIT 10;
                    '
    , array($fromDate,$toDate));
                 
    store the result in a table
    and show the Top Contributors from the table not directly from the sql query

    thanks
     
    gordy, wdb and bousaid like this.
  9. wdb

    wdb Active Member


    Ahh I see you are right, thanks for pointing that out, fixing it now.
     
    ArnyVee, bellegend and ragtek like this.
  10. HWS

    HWS Well-Known Member

    Even if you run this query only once per day on a large forum, it will block your database for hours (if you use MYISAM) or need massive ressources (if you use InnoDB, as recommended).

    If you really want statistical data for single months you need an extra table in the database where you store the posting and like count for each user in the row for the current month at the moment he/she is posting.
     
    bellegend likes this.
  11. wdb

    wdb Active Member

    Hi, thanks for the tip that makes a lot of sense.
    I will try and add caching, do you know if there is any special XenForo function I should be using or do I just create the table and read/write the cache using normal SQL queries ?
     
  12. bellegend

    bellegend Member

    you are welcom
    for big forums you must enable caching
    see here http://xenforo.com/community/threads/xenforo-caching-amazing.32629/#post-378974
    for my suggestion keep it simple
    just create the table and read/write the cache using normal SQL queries
    and create Cron Entry that Automatically run once a day
    http://xenforo.com/community/resources/how-to-create-a-cron-entry-to-move-threads-with-options.317/
     
    bousaid likes this.
  13. X_Plaza

    X_Plaza Active Member

    Excellent. Thanks for that
     
  14. wdb

    wdb Active Member

    Caching should be implemented now. It would be good to hear what sort of performance people are seeing. On the forum I've been testing it on (>250k messages) an uncached page takes roughly 1 to 2 seconds longer for the browser to render than a forum thread, for a cached page there is no noticeable difference.
     
  15. bousaid

    bousaid Well-Known Member

    yes tested .. cannot be used at larger boards ;)
    Thank you wdb, nice addone
     
  16. Eagle

    Eagle Well-Known Member

    Thank you for this but please let me know how to we would fix names of month in Turkish language?
     
  17. wdb

    wdb Active Member

    See if this works:
    Edit the file library/TopUsers/TopUsers.php

    Find the line near the bottom
    PHP:
    $returnData['month_str'] = date('F-Y',$fromDate);
    try replacing it with
    PHP:
    setlocale(LC_TIME'tr_TR');
    $returnData['month_str'] = strftime('%B %Y',$fromDate);
    if that doesn't work you can display a number instead of a month name with
    PHP:
    $returnData['month_str'] = date('m-Y',$fromDate);
     
    Eagle likes this.
  18. Eagle

    Eagle Well-Known Member

    Problem solved now thank you! : )
    But I have a question; Why SEO is not working?
    Thanks.
     
  19. wdb

    wdb Active Member


    I think I see the problem, I will fix that in the next version.

    the code near the top of the top_users_index template needs to look like this
    Code:
    <div class="topUsersSelection">
        <xen:if is="{$topUsers.month_down}">
            <a href="{xen:link 'top-users/{$topUsers.month_id_minus}'}"><div class="isSel">Previous Month</div></a>
        </xen:if>
        <xen:if is="{$topUsers.month_up}">
            <a href="{xen:link 'top-users/{$topUsers.month_id_plus}'}"><div class="isSel">Next Month</div></a>
        </xen:if>
    </div>
    actually I forgot to use phrases there too, I'll fix that also
     
    Eagle likes this.
  20. Eagle

    Eagle Well-Known Member

    Thank you again but now I see an another the problem.. When looking the page then "Viewing unknown page" on membercards or member profiles. You'd try it and see that problem.
     

Share This Page