Skip to content

Commit

Permalink
simplify query when counting own studies
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Feb 18, 2025
1 parent 36c128c commit 5ecebd8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/study/src/main/StudyRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ final class StudyRepo(private[study] val coll: AsyncColl)(using
private def hasMemberOrIsPublic(using as: Option[MyId]) = as.fold(selectPublic): me =>
$or($doc(s"members.$me".$exists(true)), selectPublic)

def countByOwner(ownerId: UserId)(using Option[MyId]) = coll:
_.countSel(selectOwnerId(ownerId) ++ hasMemberOrIsPublic)
def countByOwner(ownerId: UserId)(using as: Option[MyId]) = coll:
_.countSel(selectOwnerId(ownerId) ++ as.forall(_.isnt(ownerId)).so(hasMemberOrIsPublic))

def sourceByOwner(ownerId: UserId, isMe: Boolean): Source[Study, ?] =
Source.futureSource:
Expand Down

0 comments on commit 5ecebd8

Please sign in to comment.