Skip to content
Snippets Groups Projects
Commit e5dace3e authored by srosse's avatar srosse
Browse files

OO-3584: fix some queries which returns too much results or duplicates

results
parent 668a6330
No related branches found
No related tags found
No related merge requests found
...@@ -381,6 +381,7 @@ public class RepositoryEntryMyCourseQueries { ...@@ -381,6 +381,7 @@ public class RepositoryEntryMyCourseQueries {
} }
} }
//+ membership //+ membership
sb.append("(");
if(inRoles.isEmpty() && !membershipMandatory) { if(inRoles.isEmpty() && !membershipMandatory) {
//sub select are very quick //sub select are very quick
sb.append("(v.allUsers=true and v.status ").in(RepositoryEntryStatusEnum.publishedAndClosed()).append(") or "); sb.append("(v.allUsers=true and v.status ").in(RepositoryEntryStatusEnum.publishedAndClosed()).append(") or ");
...@@ -409,7 +410,7 @@ public class RepositoryEntryMyCourseQueries { ...@@ -409,7 +410,7 @@ public class RepositoryEntryMyCourseQueries {
if(or) sb.append(" or "); if(or) sb.append(" or ");
sb.append(" (membership.role='").append(GroupRoles.participant).append("' and v.status ").in(RepositoryEntryStatusEnum.publishedAndClosed()).append(")"); sb.append(" (membership.role='").append(GroupRoles.participant).append("' and v.status ").in(RepositoryEntryStatusEnum.publishedAndClosed()).append(")");
} }
sb.append(" ))"); sb.append(")))");
return true; return true;
} }
......
...@@ -76,7 +76,7 @@ public class RepositoryEntryQueries { ...@@ -76,7 +76,7 @@ public class RepositoryEntryQueries {
query.append("select count(v.key) from repositoryentry v "); query.append("select count(v.key) from repositoryentry v ");
query.append(" inner join v.olatResource as res"); query.append(" inner join v.olatResource as res");
} else if(params.getParentEntry() != null) { } else if(params.getParentEntry() != null) {
query.append("select v from ").append(CatalogEntry.class.getName()).append(" cei ") query.append("select distinct v from ").append(CatalogEntry.class.getName()).append(" cei ")
.append(" inner join cei.parent parentCei") .append(" inner join cei.parent parentCei")
.append(" inner join cei.repositoryEntry v") .append(" inner join cei.repositoryEntry v")
.append(" inner join fetch v.olatResource as res") .append(" inner join fetch v.olatResource as res")
...@@ -194,7 +194,7 @@ public class RepositoryEntryQueries { ...@@ -194,7 +194,7 @@ public class RepositoryEntryQueries {
*/ */
private boolean appendAccessSubSelects(QueryBuilder sb, Roles roles, boolean onlyExplicitMember) { private boolean appendAccessSubSelects(QueryBuilder sb, Roles roles, boolean onlyExplicitMember) {
if(roles.isGuestOnly()) { if(roles.isGuestOnly()) {
sb.append(" where v.guests=true and v.status not in ('").append(RepositoryEntryStatusEnum.trash).append("','").append(RepositoryEntryStatusEnum.deleted).append("')"); sb.append(" where v.guests=true and v.status ").in(RepositoryEntryStatusEnum.publishedAndClosed());
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment