Skip to content

Commit

Permalink
Merge branch '3.0' into 3
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Mar 30, 2023
2 parents 412cfeb + 234e7f6 commit 8a15c3f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ on:
push:
pull_request:
workflow_dispatch:
# Every Wednesday at 12:00pm UTC
schedule:
- cron: '0 12 * * 3'

jobs:
ci:
name: CI
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
16 changes: 16 additions & 0 deletions .github/workflows/dispatch-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Dispatch CI

on:
# At 12:00 PM UTC, only on Wednesday and Thursday
schedule:
- cron: '0 12 * * 3,4'

jobs:
dispatch-ci:
name: Dispatch CI
# Only run cron on the silverstripe account
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
runs-on: ubuntu-latest
steps:
- name: Dispatch CI
uses: silverstripe/gha-dispatch-ci@v1
10 changes: 10 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[main]
host = https://www.transifex.com

[o:silverstripe:p:silverstripe-crontask:r:master]
file_filter = lang/<lang>.yml
source_file = lang/en.yml
source_lang = en
type = YML


Empty file added lang/_manifest_exclude
Empty file.
18 changes: 18 additions & 0 deletions lang/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
en:
SilverStripe\CronTask\Controllers\CronTaskController:
NO_IMPLEMENTERS: 'There are no implementators of CronTask to run'
WILL_RUN_AT: '{task} will run at {time}.'
WILL_START_NOW: '{task} will start now.'
SilverStripe\CronTask\CronTaskController:
NO_IMPLEMENTERS: 'There are no implementators of CronTask to run'
WILL_RUN_AT: '{task} will run at {time}.'
WILL_START_NOW: '{task} will start now.'
SilverStripe\CronTask\CronTaskStatus:
PLURALNAME: 'Cron Task Statuss'
PLURALS:
one: 'A Cron Task Status'
other: '{count} Cron Task Statuss'
SINGULARNAME: 'Cron Task Status'
db_LastChecked: 'Last checked'
db_LastRun: 'Last run'
db_TaskClass: 'Task class'
13 changes: 10 additions & 3 deletions src/Controllers/CronTaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function index(HTTPRequest $request)
// Check each task
$tasks = ClassInfo::implementorsOf(CronTask::class);
if (empty($tasks)) {
$this->output("There are no implementators of CronTask to run", 2);
$this->output(_t(self::class . '.NO_IMPLEMENTERS', 'There are no implementators of CronTask to run'), 2);
return;
}
foreach ($tasks as $subclass) {
Expand All @@ -134,10 +134,17 @@ public function runTask(CronTask $task)
// Update status of this task prior to execution in case of interruption
CronTaskStatus::update_status(get_class($task), $isDue);
if ($isDue) {
$this->output(get_class($task) . ' will start now.');
$this->output(_t(self::class . '.WILL_START_NOW', '{task} will start now.', ['task' => get_class($task)]));
$task->process();
} else {
$this->output(get_class($task) . ' will run at ' . $cron->getNextRunDate()->format('Y-m-d H:i:s') . '.', 2);
$this->output(
_t(
self::class . '.WILL_RUN_AT',
'{task} will run at {time}.',
['task' => get_class($task), 'time' => $cron->getNextRunDate()->format('Y-m-d H:i:s')]
),
2
);
}
}

Expand Down

0 comments on commit 8a15c3f

Please sign in to comment.