Skip to content

Commit 417ce8f

Browse files
authored
Rename parameter in findAllListableExplorationals (#8208)
1 parent 42f1c52 commit 417ce8f

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

app/controllers/AnnotationController.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,7 @@ class AnnotationController @Inject()(
545545
annotationInfos <- annotationDAO.findAllListableExplorationals(
546546
isFinished,
547547
None,
548-
isForOwnDashboard = true,
549-
AnnotationType.Explorational,
548+
filterOwnedOrShared = true,
550549
limit.getOrElse(annotationService.DefaultAnnotationListLimit),
551550
pageNumber.getOrElse(0)
552551
)

app/controllers/UserController.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ class UserController @Inject()(userService: UserService,
6363
annotations <- annotationDAO.findAllListableExplorationals(
6464
isFinished,
6565
Some(request.identity._id),
66-
isForOwnDashboard = true,
67-
AnnotationType.Explorational,
66+
filterOwnedOrShared = true,
6867
limit.getOrElse(annotationService.DefaultAnnotationListLimit),
6968
pageNumber.getOrElse(0)
7069
)
@@ -118,8 +117,7 @@ class UserController @Inject()(userService: UserService,
118117
annotations <- annotationDAO.findAllListableExplorationals(
119118
isFinished,
120119
Some(userIdValidated),
121-
isForOwnDashboard = false,
122-
AnnotationType.Explorational,
120+
filterOwnedOrShared = false,
123121
limit.getOrElse(annotationService.DefaultAnnotationListLimit),
124122
pageNumber.getOrElse(0)
125123
)

app/models/annotation/Annotation.scala

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,20 +359,34 @@ class AnnotationDAO @Inject()(sqlClient: SqlClient, annotationLayerDAO: Annotati
359359
// format: on
360360
}
361361

362+
/**
363+
* Find all annotations which are listable by the user specified in 'forUser'
364+
*
365+
* @param isFinished
366+
* If set to `true`, only finished annotations are returned. If set to `false`, only active annotations are returned.
367+
* If set to `None`, all non-cancelled annotations are returned.
368+
* @param forUser
369+
* If set, only annotations of this user are returned. If not set, all annotations are returned.
370+
* @param filterOwnedOrShared
371+
* If `true`, the function lists only annotations owned by the user or explicitly shared with them (used for the
372+
* user's own dashboard). If `false`, it lists all annotations the viewer is allowed to see.
373+
* @param limit
374+
* The maximum number of annotations to return.
375+
* @param pageNumber
376+
* The page number to return. The first page is 0.
377+
*/
362378
def findAllListableExplorationals(
363379
isFinished: Option[Boolean],
364380
forUser: Option[ObjectId],
365-
// In dashboard, list only own + explicitly shared annotations. When listing those of another user, list all of their annotations the viewer is allowed to see
366-
isForOwnDashboard: Boolean,
367-
typ: AnnotationType,
381+
filterOwnedOrShared: Boolean,
368382
limit: Int,
369383
pageNumber: Int = 0)(implicit ctx: DBAccessContext): Fox[List[AnnotationCompactInfo]] =
370384
for {
371-
accessQuery <- if (isForOwnDashboard) accessQueryFromAccessQWithPrefix(listAccessQ, q"a.")
385+
accessQuery <- if (filterOwnedOrShared) accessQueryFromAccessQWithPrefix(listAccessQ, q"a.")
372386
else accessQueryFromAccessQWithPrefix(readAccessQWithPrefix, q"a.")
373387
stateQuery = getStateQuery(isFinished)
374388
userQuery = forUser.map(u => q"a._user = $u").getOrElse(q"TRUE")
375-
typQuery = q"a.typ = $typ"
389+
typQuery = q"a.typ = ${AnnotationType.Explorational}"
376390

377391
query = q"""WITH
378392
-- teams_agg is extracted to avoid left-join fanout.

0 commit comments

Comments
 (0)