]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do the filtering on the DB instead
authorCarl Schwan <carl@carlschwan.eu>
Thu, 13 Oct 2022 11:44:37 +0000 (13:44 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Thu, 13 Oct 2022 14:19:11 +0000 (16:19 +0200)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
apps/user_status/lib/Dashboard/UserStatusWidget.php
apps/user_status/lib/Db/UserStatusMapper.php

index 50cca725a55da56468d2cd8a6520c06a3b4d634c..5a89040dfa58713338fd5f3a212758719638209d 100644 (file)
@@ -152,8 +152,7 @@ class UserStatusWidget implements IAPIWidget, IIconWidget, IOptionWidget {
                                $this->service->findAllRecentStatusChanges($limit + 1, 0),
                                static function (UserStatus $status) use ($userId, $since): bool {
                                        return $status->getUserId() !== $userId
-                                               && ($since === null || $status->getStatusTimestamp() > (int) $since)
-                                               && !str_starts_with($status->getUserId(), "_");
+                                               && ($since === null || $status->getStatusTimestamp() > (int) $since);
                                }
                        ),
                        0,
index 4f48ea4681892009f2cb2bfc744f58f407936c1f..cb7ad5392db830ecae047d08799071c6d348b231 100644 (file)
@@ -76,10 +76,15 @@ class UserStatusMapper extends QBMapper {
                        ->select('*')
                        ->from($this->tableName)
                        ->orderBy('status_timestamp', 'DESC')
-                       ->where($qb->expr()->notIn('status', $qb->createNamedParameter([IUserStatus::ONLINE, IUserStatus::AWAY, IUserStatus::OFFLINE], IQueryBuilder::PARAM_STR_ARRAY)))
-                       ->orWhere($qb->expr()->isNotNull('message_id'))
-                       ->orWhere($qb->expr()->isNotNull('custom_icon'))
-                       ->orWhere($qb->expr()->isNotNull('custom_message'));
+                       ->where($qb->expr()->andX(
+                               $qb->expr()->orX(
+                                       $qb->expr()->notIn('status', $qb->createNamedParameter([IUserStatus::ONLINE, IUserStatus::AWAY, IUserStatus::OFFLINE], IQueryBuilder::PARAM_STR_ARRAY)),
+                                       $qb->expr()->isNotNull('message_id'),
+                                       $qb->expr()->isNotNull('custom_icon'),
+                                       $qb->expr()->isNotNull('custom_message'),
+                               ),
+                               $qb->expr()->notLike('user_id', $qb->createNamedParameter('\_%'))
+                       ));
 
                if ($limit !== null) {
                        $qb->setMaxResults($limit);