current init
This commit is contained in:
39
backend/src/Repository/TaskSchemaRepository.php
Normal file
39
backend/src/Repository/TaskSchemaRepository.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\TaskSchema;
|
||||
use App\Enum\TaskSchemaStatus;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<TaskSchema>
|
||||
*/
|
||||
class TaskSchemaRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, TaskSchema::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TaskSchema[]
|
||||
*/
|
||||
public function findActiveTasksInRange(\DateTimeInterface $from, \DateTimeInterface $to): array
|
||||
{
|
||||
return $this->createQueryBuilder('t')
|
||||
->where('t.status != :excluded')
|
||||
->andWhere(
|
||||
'(t.taskType = :einzel AND (t.deadline IS NULL OR (t.deadline >= :from AND t.deadline <= :to)))'
|
||||
. ' OR '
|
||||
. '(t.taskType != :einzel AND t.startDate <= :to AND (t.endDate IS NULL OR t.endDate >= :from))'
|
||||
)
|
||||
->setParameter('excluded', TaskSchemaStatus::Inactive)
|
||||
->setParameter('einzel', 'einzel')
|
||||
->setParameter('from', $from)
|
||||
->setParameter('to', $to)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user