Skip to content
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

Allow getting the unread comment count for an entire folder at once #4146

Merged
merged 6 commits into from
Apr 10, 2017

Conversation

icewind1991
Copy link
Member

Instead of doing 2 queries per file in a folder, we do a single query to get all unread comment counts.

comparison with 100 files

@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Mar 29, 2017
@icewind1991 icewind1991 added this to the Nextcloud 12.0 milestone Mar 29, 2017
@mention-bot
Copy link

@icewind1991, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nickvergessen, @blizzz and @LukasReschke to be potential reviewers.

@rullzer rullzer added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Mar 29, 2017
Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

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

Can we haz tests....

@icewind1991
Copy link
Member Author

@rullzer you haz your test

@icewind1991 icewind1991 added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Mar 29, 2017
->innerJoin('c', 'filecache', 'f', $qb->expr()->andX(
$qb->expr()->eq('c.object_type', $qb->createNamedParameter('files')),
$qb->expr()->eq('f.fileid', $qb->createFunction(
'cast(' . $qb->getColumnName('c.object_id') . ' as ' . $castAs . ')'
Copy link
Member

Choose a reason for hiding this comment

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

Please use $query->expr()->castColumn()

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@rullzer
Copy link
Member

rullzer commented Mar 30, 2017

@icewind1991 tests are failing...

Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 force-pushed the unread-comments-folder branch from 8f22a3f to 11c1e5d Compare March 30, 2017 10:49
@icewind1991
Copy link
Member Author

@rullzer all green

Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

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

Fine by me then!

$parentPath = '/';
}
// if we already cached the folder this file is in we know there are no shares for this file
if (array_search($parentPath, $this->cachedFolders) === false) {
Copy link
Member

Choose a reason for hiding this comment

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

It's faster to use the $parentPath as key and checking it's presence. OTOH, there won't be much in this cache, will it?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer to use a regular array and array_search here, performance shouldn't matter since this entire branch is an edge case anyway

* @return array [$fileId => $unreadCount]
* @since 12.0.0
*/
public function getNumberOfUnreadCommentsForFolder($folderId, IUser $user);
Copy link
Member

Choose a reason for hiding this comment

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

Release notes, if we had them, would be a good place to mention this addition :)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

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

Still works in the WebUI as well 👍

@MorrisJobke MorrisJobke merged commit a045f3c into master Apr 10, 2017
@MorrisJobke MorrisJobke deleted the unread-comments-folder branch April 10, 2017 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants