Skip to content

Commit

Permalink
Merge pull request #16982 from boriskrisanov/exclude-private-studies-…
Browse files Browse the repository at this point in the history
…from-count

Exclude private studies from profile count
  • Loading branch information
ornicar authored Feb 18, 2025
2 parents a052eaa + 5ecebd8 commit 2e36282
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/study/src/main/StudyRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ final class StudyRepo(private[study] val coll: AsyncColl)(using
def selectBroadcast = selectTopic(StudyTopic.broadcast)
private[study] def selectNotBroadcast = $doc(F.topics.$ne(StudyTopic.broadcast))

def countByOwner(ownerId: UserId) = coll(_.countSel(selectOwnerId(ownerId)))
private def hasMemberOrIsPublic(using as: Option[MyId]) = as.fold(selectPublic): me =>
$or($doc(s"members.$me".$exists(true)), selectPublic)

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 2e36282

Please sign in to comment.