-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API: allow requesting notes list in chunks
- Loading branch information
Showing
12 changed files
with
265 additions
and
58 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,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\Notes\Controller; | ||
|
||
use OCA\Notes\Service\MetaNote; | ||
|
||
class ChunkCursor { | ||
/** @var \DateTime */ | ||
public $timeStart; | ||
/** @var integer */ | ||
public $noteLastUpdate; | ||
/** @var integer */ | ||
public $noteId; | ||
|
||
public static function fromString(string $str) : ?ChunkCursor { | ||
if (preg_match('/^(\d+)-(\d+)-(\d+)$/', $str, $matches)) { | ||
$cc = new static(); | ||
$cc->timeStart = new \DateTime(); | ||
$cc->timeStart->setTimestamp((int)$matches[1]); | ||
$cc->noteLastUpdate = (int)$matches[2]; | ||
$cc->noteId = (int)$matches[3]; | ||
return $cc; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
public static function fromNote(\DateTime $timeStart, MetaNote $m) : ChunkCursor { | ||
$cc = new static(); | ||
$cc->timeStart = $timeStart; | ||
$cc->noteLastUpdate = $m->meta->getLastUpdate(); | ||
$cc->noteId = $m->note->getId(); | ||
return $cc; | ||
} | ||
|
||
public function toString() : string { | ||
return $this->timeStart->getTimestamp() . '-' . $this->noteLastUpdate . '-' . $this->noteId; | ||
} | ||
} |
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
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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\Notes\Service; | ||
|
||
use OCA\Notes\Db\Meta; | ||
|
||
class MetaNote { | ||
/** @var Note */ | ||
public $note; | ||
/** @var Meta */ | ||
public $meta; | ||
|
||
public function __construct(Note $note, Meta $meta) { | ||
$this->note = $note; | ||
$this->meta = $meta; | ||
} | ||
} |
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
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
Oops, something went wrong.