diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-01-14 13:09:01 +0300 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-01-14 13:09:01 +0300 |
commit | 0ba5499ee6f1a8fa45718549140a8a0547a032ee (patch) | |
tree | 1f9f3c379f65d4969278271b092c3db067929172 | |
parent | 69947fc9f46ee40912bca36c05f0f428408d54a1 (diff) |
save error message on index
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r-- | appinfo/database.xml | 7 | ||||
-rw-r--r-- | lib/Db/IndexesRequest.php | 3 | ||||
-rw-r--r-- | lib/Db/IndexesRequestBuilder.php | 4 | ||||
-rw-r--r-- | lib/Model/Index.php | 32 |
4 files changed, 45 insertions, 1 deletions
diff --git a/appinfo/database.xml b/appinfo/database.xml index 2e18279..ad83a72 100644 --- a/appinfo/database.xml +++ b/appinfo/database.xml @@ -72,6 +72,13 @@ </field> <field> + <name>message</name> + <type>text</type> + <length>3000</length> + <notnull>false</notnull> + </field> + + <field> <name>indexed</name> <type>integer</type> <length>6</length> diff --git a/lib/Db/IndexesRequest.php b/lib/Db/IndexesRequest.php index a4a8dca..35e03f7 100644 --- a/lib/Db/IndexesRequest.php +++ b/lib/Db/IndexesRequest.php @@ -49,6 +49,7 @@ class IndexesRequest extends IndexesRequestBuilder { ->setValue('provider_id', $qb->createNamedParameter($index->getProviderId())) ->setValue('document_id', $qb->createNamedParameter($index->getDocumentId())) ->setValue('err', $qb->createNamedParameter($index->getError())) + ->setValue('message', $qb->createNamedParameter($index->getMessage())) ->setValue('status', $qb->createNamedParameter($index->getStatus())) ->setValue('indexed', $qb->createNamedParameter($index->getLastIndex())); @@ -85,6 +86,8 @@ class IndexesRequest extends IndexesRequestBuilder { $qb->set('indexed', $qb->createNamedParameter($index->getLastIndex())); } + $qb->set('message', $qb->createNamedParameter($index->getMessage())); + $this->limitToProviderId($qb, $index->getProviderId()); $this->limitToDocumentId($qb, $index->getDocumentId()); diff --git a/lib/Db/IndexesRequestBuilder.php b/lib/Db/IndexesRequestBuilder.php index 53d8b62..d058322 100644 --- a/lib/Db/IndexesRequestBuilder.php +++ b/lib/Db/IndexesRequestBuilder.php @@ -85,7 +85,8 @@ class IndexesRequestBuilder extends CoreRequestBuilder { /** @noinspection PhpMethodParametersCountMismatchInspection */ $qb->select( - 'li.owner_id', 'li.provider_id', 'li.document_id', 'li.status', 'li.err', 'li.indexed' + 'li.owner_id', 'li.provider_id', 'li.document_id', 'li.status', 'li.err', 'li.message', + 'li.indexed' ) ->from(self::TABLE_INDEXES, 'li'); @@ -117,6 +118,7 @@ class IndexesRequestBuilder extends CoreRequestBuilder { $index = new ExtendedIndex($data['provider_id'], $data['document_id']); $index->setStatus($data['status']) ->setError($data['err']) + ->setMessage($data['message']) ->setOwnerId($data['owner_id']) ->setLastIndex($data['indexed']); diff --git a/lib/Model/Index.php b/lib/Model/Index.php index 9924871..ca375d0 100644 --- a/lib/Model/Index.php +++ b/lib/Model/Index.php @@ -59,6 +59,9 @@ class Index implements \JsonSerializable { /** @var int */ private $err = 0; + /** @var string */ + private $message; + /** @var int */ private $lastIndex = 0; @@ -146,6 +149,7 @@ class Index implements \JsonSerializable { $this->status -= $status; } + /** * @param int $err * @@ -164,6 +168,34 @@ class Index implements \JsonSerializable { return $this->err; } + /** + * @return $this + */ + public function incrementError() { + $this->err++; + + return $this; + } + + + /** + * @return string + */ + public function getMessage() { + return $this->message; + } + + /** + * @param string $message + * + * @return Index + */ + public function setMessage($message) { + $this->message = $message; + + return $this; + } + /** * @param int $lastIndex |