Add demotion

This commit is contained in:
Daniel_I_Am 2020-09-23 19:42:27 +02:00
parent 1ed3621b7e
commit 1516a36a13
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84
2 changed files with 23 additions and 1 deletions

View File

@ -36,6 +36,27 @@ class HelixRankCheckController extends Controller
return $e;
}, $members);
$mostRecentTimestamp = array_reduce($members, function($c, $e) {
$lastSeen = Carbon::parse($e['lastSeen']);
if ($lastSeen > $c)
return $lastSeen;
return $c;
}, Carbon::createFromTimestamp(0));
$demotionTimestamp = $mostRecentTimestamp->subHours(config('chaosapi.helix.demotion_time_hours', 3));
$members = array_filter($members, function($e) use ($demotionTimestamp) {
if ($e['lastSeen'] > $demotionTimestamp) {
return true;
}
// User should be removed from our system regarding Helix
$fcRankedUser = FreeCompanyRankedUser::find($e['lodestoneId']);
if ($fcRankedUser !== null)
$fcRankedUser->delete();
return false;
});
return [
'success' => true,
'error' => null,

View File

@ -10,6 +10,7 @@ return [
"Recruit" => 0,
"Initiate" => 14,
"Member" => 44,
]
],
'demotion_time_hours' => 5
]
];