-
Notifications
You must be signed in to change notification settings - Fork 346
cover images #2858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
cover images #2858
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -79,18 +79,10 @@ public function __construct( | |
| * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException | ||
| * @throws DoesNotExistException | ||
| */ | ||
| public function find($id, $withLabels = false, $withAcl = false): Board { | ||
| if (!isset($this->boardCache[$id])) { | ||
| $qb = $this->db->getQueryBuilder(); | ||
| $qb->select('*') | ||
| ->from('deck_boards') | ||
| ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))) | ||
| ->orderBy('id'); | ||
| $this->boardCache[$id] = $this->findEntity($qb); | ||
| } | ||
|
|
||
| // FIXME is this necessary? it was NOT done with the old mapper | ||
| // $this->mapOwner($board); | ||
| public function find($id, $withLabels = false, $withAcl = false) { | ||
| $sql = 'SELECT id, title, owner, color, archived, deleted_at, last_modified, cover_images FROM `*PREFIX*deck_boards` ' . | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure if we should rather make this a user setting. In any case we should reuse the ConfigService for this instead of adding more fields to the board table to keep it flexible. |
||
| 'WHERE `id` = ?'; | ||
| $board = $this->findEntity($sql, [$id]); | ||
|
|
||
| // Add labels | ||
| if ($withLabels && $this->boardCache[$id]->getLabels() === null) { | ||
|
|
@@ -137,16 +129,9 @@ public function findAllForUser(string $userId, ?int $since = null, bool $include | |
| * @param null $offset | ||
| * @return array | ||
| */ | ||
| public function findAllByUser(string $userId, ?int $limit = null, ?int $offset = null, ?int $since = null, | ||
| bool $includeArchived = true, ?int $before = null, ?string $term = null) { | ||
| // FIXME this used to be a UNION to get boards owned by $userId and the user shares in one single query | ||
| // Is it possible with the query builder? | ||
| $qb = $this->db->getQueryBuilder(); | ||
| $qb->select('id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified') | ||
| // this does not work in MySQL/PostgreSQL | ||
| //->selectAlias('0', 'shared') | ||
| ->from('deck_boards', 'b') | ||
| ->where($qb->expr()->eq('owner', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))); | ||
| public function findAllByUser($userId, $limit = null, $offset = null, $since = -1, $includeArchived = true) { | ||
| // FIXME: One moving to QBMapper we should allow filtering the boards probably by method chaining for additional where clauses | ||
| $sql = 'SELECT id, title, owner, color, archived, deleted_at, 0 as shared, last_modified, cover_images FROM `*PREFIX*deck_boards` WHERE owner = ? AND last_modified > ?'; | ||
| if (!$includeArchived) { | ||
| $qb->andWhere($qb->expr()->eq('archived', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL))) | ||
| ->andWhere($qb->expr()->eq('deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))); | ||
|
|
@@ -157,38 +142,9 @@ public function findAllByUser(string $userId, ?int $limit = null, ?int $offset = | |
| if ($before !== null) { | ||
| $qb->andWhere($qb->expr()->lt('last_modified', $qb->createNamedParameter($before, IQueryBuilder::PARAM_INT))); | ||
| } | ||
| if ($term !== null) { | ||
| $qb->andWhere( | ||
| $qb->expr()->iLike( | ||
| 'title', | ||
| $qb->createNamedParameter( | ||
| '%' . $this->db->escapeLikeParameter($term) . '%', | ||
| IQueryBuilder::PARAM_STR | ||
| ) | ||
| ) | ||
| ); | ||
| } | ||
| $qb->orderBy('b.id'); | ||
| if ($limit !== null) { | ||
| $qb->setMaxResults($limit); | ||
| } | ||
| if ($offset !== null) { | ||
| $qb->setFirstResult($offset); | ||
| } | ||
| $entries = $this->findEntities($qb); | ||
| foreach ($entries as $entry) { | ||
| $entry->setShared(0); | ||
| } | ||
|
|
||
| // shared with user | ||
| $qb->resetQueryParts(); | ||
| $qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified') | ||
| //->selectAlias('1', 'shared') | ||
| ->from('deck_boards', 'b') | ||
| ->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id')) | ||
| ->where($qb->expr()->eq('acl.participant', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))) | ||
| ->andWhere($qb->expr()->eq('acl.type', $qb->createNamedParameter(Acl::PERMISSION_TYPE_USER, IQueryBuilder::PARAM_INT))) | ||
| ->andWhere($qb->expr()->neq('b.owner', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))); | ||
| $sql .= ' UNION ' . | ||
| 'SELECT boards.id, title, owner, color, archived, deleted_at, 1 as shared, last_modified, cover_images FROM `*PREFIX*deck_boards` as boards ' . | ||
| 'JOIN `*PREFIX*deck_board_acl` as acl ON boards.id=acl.board_id WHERE acl.participant=? AND acl.type=? AND boards.owner != ? AND last_modified > ?'; | ||
| if (!$includeArchived) { | ||
| $qb->andWhere($qb->expr()->eq('archived', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL))) | ||
| ->andWhere($qb->expr()->eq('deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))); | ||
|
|
@@ -259,14 +215,8 @@ public function findAllByGroups(string $userId, array $groups, ?int $limit = nul | |
| if (count($groups) <= 0) { | ||
| return []; | ||
| } | ||
| $qb = $this->db->getQueryBuilder(); | ||
| $qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified') | ||
| //->selectAlias('2', 'shared') | ||
| ->from('deck_boards', 'b') | ||
| ->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id')) | ||
| ->where($qb->expr()->eq('acl.type', $qb->createNamedParameter(Acl::PERMISSION_TYPE_GROUP, IQueryBuilder::PARAM_INT))) | ||
| ->andWhere($qb->expr()->neq('b.owner', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))); | ||
| $or = $qb->expr()->orx(); | ||
| $sql = 'SELECT boards.id, title, owner, color, archived, deleted_at, 2 as shared, last_modified, cover_images FROM `*PREFIX*deck_boards` as boards ' . | ||
| 'INNER JOIN `*PREFIX*deck_board_acl` as acl ON boards.id=acl.board_id WHERE owner != ? AND type=? AND ('; | ||
| for ($i = 0, $iMax = count($groups); $i < $iMax; $i++) { | ||
| $or->add( | ||
| $qb->expr()->eq('acl.participant', $qb->createNamedParameter($groups[$i], IQueryBuilder::PARAM_STR)) | ||
|
|
@@ -325,14 +275,8 @@ public function findAllByCircles(string $userId, ?int $limit = null, ?int $offse | |
| return []; | ||
| } | ||
|
|
||
| $qb = $this->db->getQueryBuilder(); | ||
| $qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified') | ||
| //->selectAlias('2', 'shared') | ||
| ->from('deck_boards', 'b') | ||
| ->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id')) | ||
| ->where($qb->expr()->eq('acl.type', $qb->createNamedParameter(Acl::PERMISSION_TYPE_CIRCLE, IQueryBuilder::PARAM_INT))) | ||
| ->andWhere($qb->expr()->neq('b.owner', $qb->createNamedParameter($userId, IQueryBuilder::PARAM_STR))); | ||
| $or = $qb->expr()->orx(); | ||
| $sql = 'SELECT boards.id, title, owner, color, archived, deleted_at, 2 as shared, last_modified, cover_images FROM `*PREFIX*deck_boards` as boards ' . | ||
| 'INNER JOIN `*PREFIX*deck_board_acl` as acl ON boards.id=acl.board_id WHERE owner != ? AND type=? AND ('; | ||
| for ($i = 0, $iMax = count($circles); $i < $iMax; $i++) { | ||
| $or->add( | ||
| $qb->expr()->eq('acl.participant', $qb->createNamedParameter($circles[$i], IQueryBuilder::PARAM_STR)) | ||
|
|
@@ -389,12 +333,9 @@ public function findAll(): array { | |
| public function findToDelete() { | ||
| // add buffer of 5 min | ||
| $timeLimit = time() - (60 * 5); | ||
| $qb = $this->db->getQueryBuilder(); | ||
| $qb->select('id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified') | ||
| ->from('deck_boards') | ||
| ->where($qb->expr()->gt('deleted_at', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))) | ||
| ->andWhere($qb->expr()->lt('deleted_at', $qb->createNamedParameter($timeLimit, IQueryBuilder::PARAM_INT))); | ||
| return $this->findEntities($qb); | ||
| $sql = 'SELECT id, title, owner, color, archived, deleted_at, last_modified, cover_images FROM `*PREFIX*deck_boards` ' . | ||
| 'WHERE `deleted_at` > 0 AND `deleted_at` < ?'; | ||
| return $this->findEntities($sql, [$timeLimit]); | ||
| } | ||
|
|
||
| public function delete(/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */ | ||
|
|
||
This file contains hidden or 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,28 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace OCA\Deck\Migration; | ||
|
|
||
| use Closure; | ||
| use OCP\DB\ISchemaWrapper; | ||
| use OCP\Migration\IOutput; | ||
| use OCP\Migration\SimpleMigrationStep; | ||
|
|
||
| class Version010400Date20210305 extends SimpleMigrationStep { | ||
| public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { | ||
| /** @var ISchemaWrapper $schema */ | ||
| $schema = $schemaClosure(); | ||
|
|
||
| // Add cover image database field | ||
| $table = $schema->getTable('deck_boards'); | ||
| if (!$table->hasColumn('cover_images')) { | ||
| $table->addColumn('cover_images', 'boolean', [ | ||
| 'notnull' => false, | ||
| 'default' => true, | ||
| ]); | ||
| return $schema; | ||
| } | ||
| return null; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need to support this in the API Controller as well for the mobile app.