- Refactor ORM annotations across entities for consistency.

- Adjusted migrations to align with refactored ORM annotations.
- Added new PHPStan and PHP-CS-Fixer configurations, including stricter rules.
- Introduced `tests/object-manager.php` to improve test environment setup.
This commit is contained in:
2025-10-04 12:40:45 +02:00
parent 3e39550c90
commit ca460cca7f
31 changed files with 155 additions and 136 deletions

View File

@@ -38,7 +38,7 @@ class CandidateRepository extends ServiceEntityRepository
select c from Tvdt\Entity\Candidate c
where c.season = :season
and lower(c.name) = lower(:name)
DQL
DQL
)->setParameter('season', $season)
->setParameter('name', $name)
->getOneOrNullResult();
@@ -57,21 +57,21 @@ class CandidateRepository extends ServiceEntityRepository
public function getScores(Quiz $quiz): array
{
return $this->getEntityManager()->createQuery(<<<DQL
select
c.id,
c.name,
sum(case when a.isRightAnswer = true then 1 else 0 end) as correct,
qc.corrections,
max(ga.created) - qc.created as time,
(sum(case when a.isRightAnswer = true then 1 else 0 end) + qc.corrections) as score
from Tvdt\Entity\Candidate c
join c.givenAnswers ga
join ga.answer a
join c.quizData qc
where qc.quiz = :quiz and ga.quiz = :quiz
group by ga.quiz, c.id, qc.id
order by score desc, time asc
DQL
select
c.id,
c.name,
count(case when a.isRightAnswer = true then 1 else null end) as correct,
qc.corrections,
max(ga.created) - qc.created as time,
(count(case when a.isRightAnswer = true then 1 else null end) + qc.corrections) as score
from Tvdt\Entity\Candidate c
join c.givenAnswers ga
join ga.answer a
join c.quizData qc
where qc.quiz = :quiz and ga.quiz = :quiz
group by ga.quiz, c.id, qc.id
order by score desc, time asc
DQL
)->setParameter('quiz', $quiz)->getResult();
}
}

View File

@@ -32,7 +32,7 @@ class QuestionRepository extends ServiceEntityRepository
and q1.quiz = :quiz
)
and qz = :quiz
DQL)
DQL)
->setMaxResults(1)
->setParameter('candidate', $candidate)
->setParameter('quiz', $candidate->getSeason()->getActiveQuiz())

View File

@@ -24,7 +24,7 @@ class SeasonRepository extends ServiceEntityRepository
{
return $this->getEntityManager()->createQuery(<<<DQL
select s from Tvdt\Entity\Season s where :user member of s.owners order by s.name
DQL
DQL
)->setParameter('user', $user)->getResult();
}
}