Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-02-2011, 02:26 PM
XRockerX XRockerX is offline
 
Join Date: Aug 2007
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Rebuild Reputation in Cron?

I already created a Cron job to set any reputation given longer than 7 days ago to 0. It works, but when the reputation is set to 0, it still shows up as a higher number on their profile.

Rebuilding the reputation fixes it, but I was wondering if I could make that a cron job, and how would I do it? I would like to add it to the end of my "Expire Reputation" job so that every time it sets old reputation to 0, it goes ahead and rebuilds the rep.

Any thoughts on how to do this easily?
Reply With Quote
  #2  
Old 09-02-2011, 02:52 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I haven't tried this, I'm just taking a stab at it by looking at the code that adds reputation, but maybe something like this: Before you delete the reputation or set it to 0,

PHP Code:
$reps $db->query_read("SELECT * FROM " TABLE_PREFIX "reputation WHERE dateline < $cutoff");
while (
$rep $db->fetch_array($reps))
{
    
$userinfo fetch_userinfo($rep['userid']);
    
$userinfo['reputation'] -= $rep['reputation'];

    
// Determine this user's reputationlevelid.
    
$reputationlevel $db->query_first_slave("
        SELECT reputationlevelid
        FROM " 
TABLE_PREFIX "reputationlevel
        WHERE 
$userinfo[reputation] >= minimumreputation
        ORDER BY minimumreputation
        DESC LIMIT 1
     "
);

     
// init user data manager
     
$userdata =& datamanager_init('User'$vbulletinERRTYPE_SILENT);
     
$userdata->set_existing($userinfo);
     
$userdata->set('reputation'$userinfo['reputation']);
     
$userdata->set('reputationlevelid'intval($reputationlevel['reputationlevelid']));

     
$userdata->pre_save();
     if (empty(
$userdata->errors))
         
$userdata->save();

Reply With Quote
  #3  
Old 09-02-2011, 11:21 PM
setishock setishock is offline
 
Join Date: Feb 2008
Location: Houma, La.
Posts: 1,177
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just out of curiosity why every 7 days you kill every one's rep? To some rep is a flag they look at to see who is most active and giving good answers to questions.
If you flush the rep why bother to have it enabled?
Reply With Quote
  #4  
Old 09-05-2011, 08:58 PM
XRockerX XRockerX is offline
 
Join Date: Aug 2007
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's just a more competitive system of reputation to prevent people from stacking up huge amounts of reputation and then logging off for months and still holding the most reputation. For example, say on day 1 they get 5 rep. Day 2, they get 5 rep. At day 7, they are left with 5 rep total instead of 10. It's to make reputation more competitive. The users try to get as much reputation as they can day by day instead of overall.


Quote:
Originally Posted by kh99 View Post
I haven't tried this, I'm just taking a stab at it by looking at the code that adds reputation, but maybe something like this: Before you delete the reputation or set it to 0,

PHP Code:
$reps $db->query_read("SELECT * FROM " TABLE_PREFIX "reputation WHERE dateline < $cutoff");
while (
$rep $db->fetch_array($reps))
{
    
$userinfo fetch_userinfo($rep['userid']);
    
$userinfo['reputation'] -= $rep['reputation'];

    
// Determine this user's reputationlevelid.
    
$reputationlevel $db->query_first_slave("
        SELECT reputationlevelid
        FROM " 
TABLE_PREFIX "reputationlevel
        WHERE 
$userinfo[reputation] >= minimumreputation
        ORDER BY minimumreputation
        DESC LIMIT 1
     "
);

     
// init user data manager
     
$userdata =& datamanager_init('User'$vbulletinERRTYPE_SILENT);
     
$userdata->set_existing($userinfo);
     
$userdata->set('reputation'$userinfo['reputation']);
     
$userdata->set('reputationlevelid'intval($reputationlevel['reputationlevelid']));

     
$userdata->pre_save();
     if (empty(
$userdata->errors))
         
$userdata->save();

Would this update the reputation? I already have code that sets reputation to 0 after the cut off. It just doesn't reflect the changes on the website after it runs.
Reply With Quote
  #5  
Old 09-05-2011, 09:13 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by XRockerX View Post
Would this update the reputation? I already have code that sets reputation to 0 after the cut off. It just doesn't reflect the changes on the website after it runs.
Well, like I said above I haven't tried it, but I got this from the code where the reputation is increased if someone clicks on the icon, but changed it to decrease instead. You're setting the row in the reputation table to 0? Then you need to update the user row as well, I think.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:46 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03457 seconds
  • Memory Usage 2,222KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete