From 675a3916bb66a2efdf93808e6402ce7d9b1013f9 Mon Sep 17 00:00:00 2001 From: Sven Strittmatter Date: Fri, 3 Jun 2022 11:50:47 +0200 Subject: [PATCH] #8 Reformat JPQL for better readability Signed-off-by: Sven Strittmatter --- .../CustomAchievableSkillRepository.java | 157 +++++++++++++++--- 1 file changed, 130 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/iteratec/teamdojo/repository/custom/CustomAchievableSkillRepository.java b/src/main/java/com/iteratec/teamdojo/repository/custom/CustomAchievableSkillRepository.java index bf3d9ecd..8dae4481 100644 --- a/src/main/java/com/iteratec/teamdojo/repository/custom/CustomAchievableSkillRepository.java +++ b/src/main/java/com/iteratec/teamdojo/repository/custom/CustomAchievableSkillRepository.java @@ -32,17 +32,40 @@ public interface CustomAchievableSkillRepository { @Query( """ SELECT DISTINCT - new com.iteratec.teamdojo.domain.custom.AchievableSkill(t.id, s.id, s.titleEN, s.titleDE, s.descriptionEN, s.descriptionDE, t.completedAt, t.verifiedAt, t.vote, t.voters, t.irrelevant, s.score, s.expiryPeriod, s.rateScore, s.rateCount) + new com.iteratec.teamdojo.domain.custom.AchievableSkill( + t.id, + s.id, + s.titleEN, + s.titleDE, + s.descriptionEN, + s.descriptionDE, + t.completedAt, + t.verifiedAt, + t.vote, + t.voters, + t.irrelevant, + s.score, + s.expiryPeriod, + s.rateScore, + s.rateCount + ) FROM Skill s LEFT JOIN s.teams t ON t.team.id = :teamId LEFT JOIN s.levels l LEFT JOIN s.badges b - WHERE (l.level.id IN :levelIds - OR b.badge.id IN :badgeIds) - AND ( - ( ('COMPLETE' IN :filter) AND (t.completedAt is not null) ) - OR ( ('INCOMPLETE' IN :filter) AND (t.completedAt is null) ) - ) + WHERE + ( + l.level.id IN :levelIds + OR b.badge.id IN :badgeIds + ) + AND ( + ( + ('COMPLETE' IN :filter) AND (t.completedAt is not null) + ) + OR ( + ('INCOMPLETE' IN :filter) AND (t.completedAt is null) + ) + ) ORDER BY s.titleEN """ ) @@ -58,15 +81,36 @@ Page findAchievableSkillsByLevelsAndBadges( @Query( """ SELECT DISTINCT - new com.iteratec.teamdojo.domain.custom.AchievableSkill(t.id, s.id, s.titleEN, s.titleDE, s.descriptionEN, s.descriptionDE, t.completedAt, t.verifiedAt, t.vote, t.voters, t.irrelevant, s.score, s.expiryPeriod, s.rateScore, s.rateCount) + new com.iteratec.teamdojo.domain.custom.AchievableSkill( + t.id, + s.id, + s.titleEN, + s.titleDE, + s.descriptionEN, + s.descriptionDE, + t.completedAt, + t.verifiedAt, + t.vote, + t.voters, + t.irrelevant, + s.score, + s.expiryPeriod, + s.rateScore, + s.rateCount + ) FROM Skill s LEFT JOIN s.teams t ON t.team.id = :teamId LEFT JOIN s.levels l - WHERE l.level.dimension.id = :dimensionId - AND ( - ( ('COMPLETE' IN :filter) AND (t.completedAt is not null) ) - OR ( ('INCOMPLETE' IN :filter) AND (t.completedAt is null) ) - ) + WHERE + l.level.dimension.id = :dimensionId + AND ( + ( + ('COMPLETE' IN :filter) AND (t.completedAt is not null) + ) + OR ( + ('INCOMPLETE' IN :filter) AND (t.completedAt is null) + ) + ) ORDER BY s.titleEN """ ) @@ -81,15 +125,36 @@ Page findAchievableSkillsByDimensions( @Query( """ SELECT DISTINCT - new com.iteratec.teamdojo.domain.custom.AchievableSkill(t.id, s.id, s.titleEN, s.titleDE, s.descriptionEN, s.descriptionDE, t.completedAt, t.verifiedAt, t.vote, t.voters, t.irrelevant, s.score, s.expiryPeriod, s.rateScore, s.rateCount) + new com.iteratec.teamdojo.domain.custom.AchievableSkill( + t.id, + s.id, + s.titleEN, + s.titleDE, + s.descriptionEN, + s.descriptionDE, + t.completedAt, + t.verifiedAt, + t.vote, + t.voters, + t.irrelevant, + s.score, + s.expiryPeriod, + s.rateScore, + s.rateCount + ) FROM Skill s LEFT JOIN s.teams t ON t.team.id = :teamId LEFT JOIN s.levels l - WHERE l.level.id IN :levelIds - AND ( - ( ('COMPLETE' IN :filter) AND (t.completedAt is not null) ) - OR ( ('INCOMPLETE' IN :filter) AND (t.completedAt is null) ) - ) + WHERE + l.level.id IN :levelIds + AND ( + ( + ('COMPLETE' IN :filter) AND (t.completedAt is not null) + ) + OR ( + ('INCOMPLETE' IN :filter) AND (t.completedAt is null) + ) + ) ORDER BY s.titleEN """ ) @@ -104,15 +169,36 @@ Page findAchievableSkillsByLevels( @Query( """ SELECT DISTINCT - new com.iteratec.teamdojo.domain.custom.AchievableSkill(t.id, s.id, s.titleEN, s.titleDE, s.descriptionEN, s.descriptionDE, t.completedAt, t.verifiedAt, t.vote, t.voters, t.irrelevant, s.score, s.expiryPeriod, s.rateScore, s.rateCount) + new com.iteratec.teamdojo.domain.custom.AchievableSkill( + t.id, + s.id, + s.titleEN, + s.titleDE, + s.descriptionEN, + s.descriptionDE, + t.completedAt, + t.verifiedAt, + t.vote, + t.voters, + t.irrelevant, + s.score, + s.expiryPeriod, + s.rateScore, + s.rateCount + ) FROM Skill s LEFT JOIN s.teams t ON t.team.id = :teamId LEFT JOIN s.badges b - WHERE b.badge.id IN :badgeIds - AND ( - ( ('COMPLETE' IN :filter) AND (t.completedAt is not null) ) - OR ( ('INCOMPLETE' IN :filter) AND (t.completedAt is null) ) - ) + WHERE + b.badge.id IN :badgeIds + AND ( + ( + ('COMPLETE' IN :filter) AND (t.completedAt is not null) + ) + OR ( + ('INCOMPLETE' IN :filter) AND (t.completedAt is null) + ) + ) ORDER BY s.titleEN """ ) @@ -127,10 +213,27 @@ Page findAchievableSkillsByBadges( @Query( """ SELECT DISTINCT - new com.iteratec.teamdojo.domain.custom.AchievableSkill(t.id, s.id, s.titleEN, s.titleDE, s.descriptionEN, s.descriptionDE, t.completedAt, t.verifiedAt, t.vote, t.voters, t.irrelevant, s.score, s.expiryPeriod, s.rateScore, s.rateCount) + new com.iteratec.teamdojo.domain.custom.AchievableSkill( + t.id, + s.id, + s.titleEN, + s.titleDE, + s.descriptionEN, + s.descriptionDE, + t.completedAt, + t.verifiedAt, + t.vote, + t.voters, + t.irrelevant, + s.score, + s.expiryPeriod, + s.rateScore, + s.rateCount + ) FROM Skill s LEFT JOIN s.teams t ON t.team.id = :teamId - WHERE s.id = :skillId + WHERE + s.id = :skillId """ ) AchievableSkill findAchievableSkill(@Param("teamId") Long teamId, @Param("skillId") Long skillId);