Skip to content

Commit

Permalink
#8 Reformat JPQL for better readability
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Strittmatter <[email protected]>
  • Loading branch information
Weltraumschaf committed Jun 3, 2022
1 parent 4cfd053 commit 675a391
Showing 1 changed file with 130 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
)
Expand All @@ -58,15 +81,36 @@ Page<AchievableSkill> 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
"""
)
Expand All @@ -81,15 +125,36 @@ Page<AchievableSkill> 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
"""
)
Expand All @@ -104,15 +169,36 @@ Page<AchievableSkill> 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
"""
)
Expand All @@ -127,10 +213,27 @@ Page<AchievableSkill> 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);
Expand Down

0 comments on commit 675a391

Please sign in to comment.