Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/dav/lib/BackgroundJob/CalendarRetentionJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __construct(ITimeFactory $time,

// Run four times a day
$this->setInterval(6 * 60 * 60);
$this->setTimeSensitivity(self::TIME_SENSITIVE);
}

protected function run($argument): void {
Expand Down
15 changes: 7 additions & 8 deletions apps/dav/lib/BackgroundJob/CleanupDirectLinksJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,25 @@
*/
namespace OCA\DAV\BackgroundJob;

use OC\BackgroundJob\TimedJob;
use OCA\DAV\Db\DirectMapper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;

class CleanupDirectLinksJob extends TimedJob {
/** @var ITimeFactory */
private $timeFactory;

/** @var DirectMapper */
private $mapper;

public function __construct(ITimeFactory $timeFactory, DirectMapper $mapper) {
$this->setInterval(60 * 60 * 24);

$this->timeFactory = $timeFactory;
parent::__construct($timeFactory);
$this->mapper = $mapper;

// Run once a day at off-peak time
$this->setInterval(24 * 60 * 60);
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
}

protected function run($argument) {
// Delete all shares expired 24 hours ago
$this->mapper->deleteExpired($this->timeFactory->getTime() - 60 * 60 * 24);
$this->mapper->deleteExpired($this->time->getTime() - 60 * 60 * 24);
}
}
15 changes: 7 additions & 8 deletions apps/dav/lib/BackgroundJob/CleanupInvitationTokenJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,29 @@
*/
namespace OCA\DAV\BackgroundJob;

use OC\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\IDBConnection;

class CleanupInvitationTokenJob extends TimedJob {

/** @var IDBConnection */
private $db;

/** @var ITimeFactory */
private $timeFactory;

public function __construct(IDBConnection $db, ITimeFactory $timeFactory) {
public function __construct(IDBConnection $db, ITimeFactory $time) {
parent::__construct($time);
$this->db = $db;
$this->timeFactory = $timeFactory;

$this->setInterval(60 * 60 * 24);
// Run once a day at off-peak time
$this->setInterval(24 * 60 * 60);
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
}

public function run($argument) {
$query = $this->db->getQueryBuilder();
$query->delete('calendar_invitations')
->where($query->expr()->lt('expiration',
$query->createNamedParameter($this->timeFactory->getTime())))
$query->createNamedParameter($this->time->getTime())))
->execute();
}
}
23 changes: 13 additions & 10 deletions apps/dav/lib/BackgroundJob/EventReminderJob.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2016 Thomas Citharel <nextcloud@tcit.fr>
*
Expand All @@ -23,8 +26,9 @@
*/
namespace OCA\DAV\BackgroundJob;

use OC\BackgroundJob\TimedJob;
use OCA\DAV\CalDAV\Reminder\ReminderService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\IConfig;

class EventReminderJob extends TimedJob {
Expand All @@ -35,17 +39,16 @@ class EventReminderJob extends TimedJob {
/** @var IConfig */
private $config;

/**
* EventReminderJob constructor.
*
* @param ReminderService $reminderService
* @param IConfig $config
*/
public function __construct(ReminderService $reminderService, IConfig $config) {
public function __construct(ITimeFactory $time,
ReminderService $reminderService,
IConfig $config) {
parent::__construct($time);
$this->reminderService = $reminderService;
$this->config = $config;
/** Run every 5 minutes */
$this->setInterval(5);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈 oops


// Run every 5 minutes
$this->setInterval(5 * 60);
$this->setTimeSensitivity(self::TIME_SENSITIVE);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright 2017 Georg Ehrke <oc.list@georgehrke.com>
*
Expand All @@ -22,8 +25,9 @@
*/
namespace OCA\DAV\BackgroundJob;

use OC\BackgroundJob\QueuedJob;
use OCA\DAV\CalDAV\BirthdayService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
use OCP\IConfig;

class GenerateBirthdayCalendarBackgroundJob extends QueuedJob {
Expand All @@ -34,14 +38,11 @@ class GenerateBirthdayCalendarBackgroundJob extends QueuedJob {
/** @var IConfig */
private $config;

/**
* GenerateAllBirthdayCalendarsBackgroundJob constructor.
*
* @param BirthdayService $birthdayService
* @param IConfig $config
*/
public function __construct(BirthdayService $birthdayService,
public function __construct(ITimeFactory $time,
BirthdayService $birthdayService,
IConfig $config) {
parent::__construct($time);

$this->birthdayService = $birthdayService;
$this->config = $config;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

namespace OCA\DAV\BackgroundJob;

use OC\BackgroundJob\TimedJob;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\Calendar\BackendTemporarilyUnavailableException;
use OCP\Calendar\IMetadataProvider;
use OCP\Calendar\Resource\IBackend as IResourceBackend;
Expand All @@ -53,17 +54,20 @@ class UpdateCalendarResourcesRoomsBackgroundJob extends TimedJob {
/** @var CalDavBackend */
private $calDavBackend;

public function __construct(IResourceManager $resourceManager,
public function __construct(ITimeFactory $time,
IResourceManager $resourceManager,
IRoomManager $roomManager,
IDBConnection $dbConnection,
CalDavBackend $calDavBackend) {
parent::__construct($time);
$this->resourceManager = $resourceManager;
$this->roomManager = $roomManager;
$this->dbConnection = $dbConnection;
$this->calDavBackend = $calDavBackend;

// run once an hour
// Run once an hour
$this->setInterval(60 * 60);
$this->setTimeSensitivity(self::TIME_SENSITIVE);
}

/**
Expand Down
18 changes: 14 additions & 4 deletions apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,37 @@

use OCA\DAV\BackgroundJob\EventReminderJob;
use OCA\DAV\CalDAV\Reminder\ReminderService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

class EventReminderJobTest extends TestCase {

/** @var ReminderService|\PHPUnit\Framework\MockObject\MockObject */
/** @var ITimeFactory|MockObject */
private $time;

/** @var ReminderService|MockObject */
private $reminderService;

/** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
/** @var IConfig|MockObject */
private $config;

/** @var EventReminderJob|\PHPUnit\Framework\MockObject\MockObject */
/** @var EventReminderJob|MockObject */
private $backgroundJob;

protected function setUp(): void {
parent::setUp();

$this->time = $this->createMock(ITimeFactory::class);
$this->reminderService = $this->createMock(ReminderService::class);
$this->config = $this->createMock(IConfig::class);

$this->backgroundJob = new EventReminderJob($this->reminderService, $this->config);
$this->backgroundJob = new EventReminderJob(
$this->time,
$this->reminderService,
$this->config,
);
}

public function data(): array {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2017, Georg Ehrke
*
Expand Down Expand Up @@ -27,15 +30,20 @@

use OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob;
use OCA\DAV\CalDAV\BirthdayService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

class GenerateBirthdayCalendarBackgroundJobTest extends TestCase {

/** @var BirthdayService | \PHPUnit\Framework\MockObject\MockObject */
/** @var ITimeFactory|MockObject */
private $time;

/** @var BirthdayService | MockObject */
private $birthdayService;

/** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */
/** @var IConfig | MockObject */
private $config;

/** @var \OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob */
Expand All @@ -44,11 +52,15 @@ class GenerateBirthdayCalendarBackgroundJobTest extends TestCase {
protected function setUp(): void {
parent::setUp();

$this->time = $this->createMock(ITimeFactory::class);
$this->birthdayService = $this->createMock(BirthdayService::class);
$this->config = $this->createMock(IConfig::class);

$this->backgroundJob = new GenerateBirthdayCalendarBackgroundJob(
$this->birthdayService, $this->config);
$this->time,
$this->birthdayService,
$this->config,
);
}

public function testRun() {
Expand Down
3 changes: 3 additions & 0 deletions apps/dav/tests/unit/BackgroundJob/RefreshWebcalJobTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2018, Georg Ehrke
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @copyright 2019 Georg Ehrke <oc.list@georgehrke.com>
*
Expand Down Expand Up @@ -45,9 +48,6 @@ class RegisterRegenerateBirthdayCalendarsTest extends TestCase {
/** @var IJobList | \PHPUnit\Framework\MockObject\MockObject */
private $jobList;

/** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */
private $config;

/** @var RegisterRegenerateBirthdayCalendars */
private $backgroundJob;

Expand All @@ -57,10 +57,12 @@ protected function setUp(): void {
$this->time = $this->createMock(ITimeFactory::class);
$this->userManager = $this->createMock(IUserManager::class);
$this->jobList = $this->createMock(IJobList::class);
$this->config = $this->createMock(IConfig::class);

$this->backgroundJob = new RegisterRegenerateBirthdayCalendars($this->time,
$this->userManager, $this->jobList);
$this->backgroundJob = new RegisterRegenerateBirthdayCalendars(
$this->time,
$this->userManager,
$this->jobList
);
}

public function testRun() {
Expand Down
Loading