Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Do the filtering on the DB instead
Signed-off-by: Carl Schwan <[email protected]>
  • Loading branch information
CarlSchwan committed Oct 13, 2022
commit 8c95e46744e03a528a2944cce40e6e189b1c1d0a
3 changes: 1 addition & 2 deletions apps/user_status/lib/Dashboard/UserStatusWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ private function getWidgetData(string $userId, ?string $since = null, int $limit
$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,
Expand Down
13 changes: 9 additions & 4 deletions apps/user_status/lib/Db/UserStatusMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@ public function findAllRecent(?int $limit = null, ?int $offset = null): array {
->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);
Expand Down