#!/usr/bin/php $projects */ $projects = array_merge( Project::GetAllByStatus(Enums\ProjectStatusType::InProgress), Project::GetAllByStatus(Enums\ProjectStatusType::Stalled) ); $apiKey = trim(file_get_contents('/standardebooks.org/config/secrets/se-vcs-bot@api.github.com')); $oldestStalledTimestamp = new DateTimeImmutable('60 days ago'); $oldestAbandonedTimestamp = new DateTimeImmutable('90 days ago'); foreach($projects as $project){ try{ $project->FetchLastDiscussionTimestamp(); } catch(Exceptions\AppException $ex){ Log::WriteErrorLogEntry($ex->getMessage()); } try{ $project->FetchLatestCommitTimestamp($apiKey); } catch(Exceptions\AppException $ex){ Log::WriteErrorLogEntry($ex->getMessage()); } if($project->IsStatusAutomaticallyUpdated){ if( $project->Status == Enums\ProjectStatusType::InProgress && $project->LastActivityTimestamp < $oldestStalledTimestamp ){ // An active `Project` has stalled. $project->Status = Enums\ProjectStatusType::Stalled; // Send an email to the producer. $project->SendReminder(Enums\ProjectReminderType::Stalled); } elseif( $project->Status == Enums\ProjectStatusType::Stalled && $project->LastActivityTimestamp >= $oldestStalledTimestamp ){ // Revive previously-stalled `Project`s. $project->Status = Enums\ProjectStatusType::InProgress; } elseif( $project->Status == Enums\ProjectStatusType::Stalled && $project->LastActivityTimestamp < $oldestStalledTimestamp && $project->GetReminder(Enums\ProjectReminderType::Stalled)?->Created < $oldestAbandonedTimestamp ){ // A stalled `Project` is now abandoned. $project->Status = Enums\ProjectStatusType::Abandoned; // Send a notification to the producer. $project->SendReminder(Enums\ProjectReminderType::Abandoned); } } $project->Save(); sleep(1); }