This repository has been archived by the owner on Aug 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cron to delete hidden mission db events after x days
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
ini_set('max_execution_time', 900); | ||
|
||
// Delete events from missions that have been "hidden". Missions are hidden because | ||
// not enough players are present or they finish too soon (usually applies to mission testing) | ||
if (!isset($_SERVER['cron'])) | ||
die('No browser access.'); | ||
|
||
require_once('../inc/bootstrap.php'); | ||
$replays = Replays::Instance(); | ||
$db = Database::Instance()->conn; | ||
|
||
// Sometimes missions can be incorrectly hidden. Let's not delete anything too recent. | ||
$daysOlderThan = MIN_DAYS_DELETE_HIDDEN_MISSION_EVENTS; | ||
$deletedReplays = []; | ||
|
||
$hiddenMissionIds = $replays->fetchHidden($daysOlderThan); | ||
|
||
foreach ($hiddenMissionIds as $mission) { | ||
if ($mission->id) { | ||
$query = $db->prepare("DELETE FROM events WHERE replayId = :id"); | ||
|
||
$query->execute(array('id' => $mission->id)); | ||
|
||
$deletedReplays[] = $mission->id; | ||
} | ||
} | ||
|
||
echo '<pre>'; | ||
print_r($deletedReplays); |
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