From 29aa0d24fae65822f04b005ba9f9c9191a648165 Mon Sep 17 00:00:00 2001 From: Jonathan Treffler Date: Sat, 2 Sep 2023 02:41:53 +0200 Subject: [PATCH] added DiffTaskResult Entity and Mapper --- lib/Db/DiffTaskResult.php | 48 +++++++++++++++++++++++++++++++++ lib/Db/DiffTaskResultMapper.php | 36 +++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 lib/Db/DiffTaskResult.php create mode 100644 lib/Db/DiffTaskResultMapper.php diff --git a/lib/Db/DiffTaskResult.php b/lib/Db/DiffTaskResult.php new file mode 100644 index 0000000..3050a12 --- /dev/null +++ b/lib/Db/DiffTaskResult.php @@ -0,0 +1,48 @@ +addType('id','integer'); + $this->addType('taskId','integer'); + $this->addType('beforeFileExists','boolean'); + $this->addType('beforeSize','integer'); + $this->addType('currentFileExists','boolean'); + $this->addType('currentSize','integer'); + } + + public function jsonSerialize() { + return [ + 'id' => $this->id, + 'taskId' => $this->taskId, + 'type' => $this->type, + 'before' => [ + 'fileExists' => $this->beforeFileExists, + 'path' => $this->beforePath, + 'size' => $this->beforeSize, + ], + 'current' => [ + 'fileExists' => $this->currentFileExists, + 'path' => $this->currentPath, + 'size' => $this->currentSize, + ] + ]; + } +} \ No newline at end of file diff --git a/lib/Db/DiffTaskResultMapper.php b/lib/Db/DiffTaskResultMapper.php new file mode 100644 index 0000000..5937829 --- /dev/null +++ b/lib/Db/DiffTaskResultMapper.php @@ -0,0 +1,36 @@ + + */ +class DiffTaskResultMapper extends QBMapper { + + public function __construct(IDBConnection $db) { + parent::__construct($db, 'groupfolder_snapshots_task_results', DiffTaskResult::class); + } + + public function find(int $id) { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); + + return $this->findEntity($qb); + } + + public function findAll(int $taskId) { + $qb = $this->db->getQueryBuilder(); + + $qb->select('*') + ->from($this->getTableName()) + ->where($qb->expr()->eq('task_id', $qb->createNamedParameter($taskId))); + + return $this->findEntities($qb); + } + +} \ No newline at end of file