-
-
Save aikar/239fe7522f047ca8acf3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define('DAY', 60 * 60 * 24); | |
define('MONTH', DAY * 31); | |
$oneMonthAgo = time()- MONTH; | |
$derelictCutoff = time() - MONTH; | |
$derelictSemiNewCutoff = time()- (DAY * 15); | |
$derelictNewCutoff = time()- (DAY * 10); | |
$derelictAbandonCutoff = time()- (DAY * 5); | |
$sql = " | |
SELECT | |
u.name, | |
u.user_group_id, | |
GREATEST(u.lastvote, u.last_activity) as last_activity, | |
u.derelict_protection, | |
r.address | |
FROM | |
residence as r | |
LEFT JOIN | |
user as u on r.owner_user_id = u.user_id | |
WHERE | |
r.owner_user_id is not null | |
AND | |
u.user_group_id < 2 | |
AND | |
u.derelict_protection = 0 | |
AND | |
( | |
GREATEST(u.lastvote, u.last_activity) < $derelictCutoff | |
OR | |
( | |
GREATEST(u.lastvote, u.last_activity) < $derelictSemiNewCutoff | |
AND | |
u.last_login - u.first_login < (60*60*24*10) | |
) | |
OR | |
( | |
GREATEST(u.lastvote, u.last_activity) < $derelictNewCutoff | |
AND | |
u.last_login - u.first_login < (60*60*24*5) | |
) | |
OR | |
( | |
GREATEST(u.lastvote, u.last_activity) < $derelictAbandonCutoff | |
AND | |
u.last_login - u.first_login < (60*60*24*1) | |
) | |
) | |
AND | |
server_id = $serverId | |
ORDER BY u.first_login + GREATEST(u.lastvote, u.last_activity) / 2 DESC | |
LIMIT $reclaimAmt"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment