Skip to content

Commit

Permalink
query fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-stanek committed Nov 14, 2024
1 parent 38a24e1 commit 5084a51
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions app/Model/Program/Repositories/BlockRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,17 @@ public function findUserAllowed(User $user, bool $paidOnly): Collection
->leftJoin('c.registerableRoles', 'r')
->leftJoin('r.users', 'u1')
->join('b.subevent', 's')
->join('s.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid')
->join('s.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered')
->join('sa.user', 'u2', 'WITH', 'u2.approved = TRUE')
->where('c IS NULL OR u1 = :user')
->andWhere('u2 = :user')
->setParameter('user', $user)
->setParameter('stateCanceled', ApplicationState::CANCELED)
->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID);
->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID)
->setParameter('stateCanceledTransfered', ApplicationState::CANCELED_TRANSFERED);

if ($paidOnly) {
$qb = $qb->join('u2.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND ra.state != :stateWaitingForPayment')
$qb = $qb->join('u2.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered AND ra.state != :stateWaitingForPayment')
->join('ra.roles', 'rar')
->andWhere('sa.state != :stateWaitingForPayment')
->setParameter('stateWaitingForPayment', ApplicationState::WAITING_FOR_PAYMENT);
Expand Down
7 changes: 4 additions & 3 deletions app/Model/Program/Repositories/ProgramRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@ public function findUserAllowed(User $user, bool $paidOnly): Collection
->leftJoin('c.registerableRoles', 'r')
->leftJoin('r.users', 'u1')
->join('b.subevent', 's')
->join('s.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid')
->join('s.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered')
->join('sa.user', 'u2', 'WITH', 'u2.approved = TRUE')
->where('c IS NULL OR u1 = :user')
->andWhere('u2 = :user')
->setParameter('user', $user)
->setParameter('stateCanceled', ApplicationState::CANCELED)
->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID);
->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID)
->setParameter('stateCanceledTransfered', ApplicationState::CANCELED_TRANSFERED);

if ($paidOnly) {
$qb = $qb->join('u2.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND ra.state != :stateWaitingForPayment')
$qb = $qb->join('u2.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered AND ra.state != :stateWaitingForPayment')
->join('ra.roles', 'rar')
->andWhere('sa.state != :stateWaitingForPayment')
->setParameter('stateWaitingForPayment', ApplicationState::WAITING_FOR_PAYMENT);
Expand Down
7 changes: 4 additions & 3 deletions app/Model/User/Repositories/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,14 @@ public function remove(User $user): void
public function blockAllowedQuery(Block $block, bool $paidOnly): QueryBuilder
{
$qb = $this->createQueryBuilder('u')
->join('u.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid')
->join('u.applications', 'sa', 'WITH', 'sa.validTo IS NULL AND sa.state != :stateCanceled AND sa.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered')
->join('sa.subevents', 's')
->where('u.approved = true')
->andWhere('s = :subevent')
->setParameter('subevent', $block->getSubevent())
->setParameter('stateCanceled', ApplicationState::CANCELED)
->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID);
->setParameter('stateCanceledNotPaid', ApplicationState::CANCELED_NOT_PAID)
->setParameter('stateCanceledTransfered', ApplicationState::CANCELED_TRANSFERED);

if ($block->getCategory() !== null) {
$qb = $qb->join('u.roles', 'r')
Expand All @@ -323,7 +324,7 @@ public function blockAllowedQuery(Block $block, bool $paidOnly): QueryBuilder
}

if ($paidOnly) {
$qb = $qb->join('u.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND ra.state != :stateWaitingForPayment')
$qb = $qb->join('u.applications', 'ra', 'WITH', 'ra.validTo IS NULL AND ra.state != :stateCanceled AND ra.state != :stateCanceledNotPaid AND sa.state != :stateCanceledTransfered AND ra.state != :stateWaitingForPayment')
->join('ra.roles', 'rar')
->andWhere('sa.state != :stateWaitingForPayment')
->setParameter('stateWaitingForPayment', ApplicationState::WAITING_FOR_PAYMENT);
Expand Down

0 comments on commit 5084a51

Please sign in to comment.