but I looking at the code and I don't understand what is the needed of modtime column in the db and the use of xtime, ytime, yytime, etc in proc karmaupdate
# $kutime is the actual timestamp
# the modification time (modtime) will be set to $kutime when a record is updated
set kutime [clock seconds]
# $xtime is 90 days before
set xtime [expr $kutime - (90 * 86400)]
# delete all karmas which are locked and with a small value (between -1 and 1) and older than 90 days
kdb eval {DELETE FROM lkarma WHERE modtime < $xtime AND karma between -1 and 1 and locked='N'}
# decrease the value of positives karma and increase the value of negative karma
# if they are between 2 and 22 (positive or negative) and older than 90 days
kdb eval {UPDATE lkarma SET karma=karma-1, modtime=$kutime WHERE modtime < $xtime AND karma between 2 and 22 AND locked='N'}
kdb eval {UPDATE lkarma SET karma=karma+1, modtime=$kutime WHERE modtime < $xtime AND karma between -22 and -2 AND locked='N'}
# $ytime is 30 days before
set ytime [expr $kutime - (30 * 86400)]
# decrease the value of positives karma and increase the value of negative karma
# if they are between 23 and 54 (positive or negative) and older than 30 days
kdb eval {UPDATE lkarma SET karma=karma-1, modtime=$kutime WHERE modtime < $ytime AND karma between 23 and 54 AND locked='N'}
kdb eval {UPDATE lkarma SET karma=karma+1, modtime=$kutime WHERE modtime < $ytime AND karma between -54 and -23 AND locked='N'}
#... and doing the same with diffrent delays and karma values
## older than 7days and between 55 and 80
## older than 2 days and between 81 and 120
## older than 1 day and between 121 and 540
## older than 8 hours (1 day / 3) and between 541 and 959
## older than 4h48 (1 day / 5) and higher than 960
The goal seems to be to make the karma going to 0 when it has not been modified for a time. Lesser (positive or negative) is your karma and slower it will decrease (tend to 0)
CrazyCat wrote:The goal seems to be to make the karma going to 0 when it has not been modified for a time. Lesser (positive or negative) is your karma and slower it will decrease (tend to 0)