This commit is contained in:
Julien Fastré 2022-10-05 15:30:55 +02:00
parent d95472ca9d
commit 642b1e43c8
22 changed files with 79 additions and 59 deletions

View File

@ -90,7 +90,6 @@ final class ActivityController extends AbstractController
SerializerInterface $serializer, SerializerInterface $serializer,
UserRepositoryInterface $userRepository, UserRepositoryInterface $userRepository,
CenterResolverManagerInterface $centerResolver CenterResolverManagerInterface $centerResolver
) { ) {
$this->activityACLAwareRepository = $activityACLAwareRepository; $this->activityACLAwareRepository = $activityACLAwareRepository;
$this->activityTypeRepository = $activityTypeRepository; $this->activityTypeRepository = $activityTypeRepository;
@ -106,7 +105,6 @@ final class ActivityController extends AbstractController
$this->serializer = $serializer; $this->serializer = $serializer;
$this->userRepository = $userRepository; $this->userRepository = $userRepository;
$this->centerResolver = $centerResolver; $this->centerResolver = $centerResolver;
} }
/** /**

View File

@ -409,16 +409,16 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
return $this->status; return $this->status;
} }
public function getUrgent(): ?bool
{
return $this->urgent;
}
public function getThirdParties(): Collection public function getThirdParties(): Collection
{ {
return $this->getProfessionals(); return $this->getProfessionals();
} }
public function getUrgent(): ?bool
{
return $this->urgent;
}
/** /**
* @return Collection|User[] * @return Collection|User[]
* @Serializer\Groups({"calendar:read", "read"}) * @Serializer\Groups({"calendar:read", "read"})
@ -599,13 +599,6 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
return $this; return $this;
} }
public function setUrgent(bool $urgent): self
{
$this->urgent = $urgent;
return $this;
}
public function setStartDate(DateTimeImmutable $startDate): self public function setStartDate(DateTimeImmutable $startDate): self
{ {
$this->startDate = $startDate; $this->startDate = $startDate;
@ -623,4 +616,11 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
return $this; return $this;
} }
public function setUrgent(bool $urgent): self
{
$this->urgent = $urgent;
return $this;
}
} }

View File

@ -21,7 +21,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class UrgencyAggregator implements AggregatorInterface class UrgencyAggregator implements AggregatorInterface
{ {
private TranslatorInterface $translator; private TranslatorInterface $translator;
public function __construct( public function __construct(
@ -88,4 +87,3 @@ class UrgencyAggregator implements AggregatorInterface
return 'Group calendars by urgency'; return 'Group calendars by urgency';
} }
} }

View File

@ -23,7 +23,6 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Exception\LogicException; use Symfony\Component\Validator\Exception\LogicException;
class CountCalendars implements ExportInterface, GroupedExportInterface class CountCalendars implements ExportInterface, GroupedExportInterface
{ {
private CalendarRepository $calendarRepository; private CalendarRepository $calendarRepository;

View File

@ -11,8 +11,8 @@ declare(strict_types=1);
namespace Chill\CalendarBundle\Export\Filter; namespace Chill\CalendarBundle\Export\Filter;
use Chill\MainBundle\Export\FilterInterface;
use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Export\Declarations;
use Chill\MainBundle\Export\FilterInterface;
use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@ -23,7 +23,7 @@ class CalendarRangeFilter implements FilterInterface
{ {
private const CHOICES = [ private const CHOICES = [
'Not made within a calendar range' => true, 'Not made within a calendar range' => true,
'Made within a calendar range' => false 'Made within a calendar range' => false,
]; ];
private const DEFAULT_CHOICE = false; private const DEFAULT_CHOICE = false;
@ -52,7 +52,6 @@ class CalendarRangeFilter implements FilterInterface
$clause = $qb->expr()->isNull('cal.calendarRange'); $clause = $qb->expr()->isNull('cal.calendarRange');
} }
if ($where instanceof Andx) { if ($where instanceof Andx) {
$where->add($clause); $where->add($clause);
} else { } else {
@ -101,4 +100,3 @@ class CalendarRangeFilter implements FilterInterface
return 'Filter by calendar range'; return 'Filter by calendar range';
} }
} }

View File

@ -143,7 +143,7 @@ class MapCalendarToUser
public function writeMetadata(User $user): User public function writeMetadata(User $user): User
{ {
if (null === $user->getEmail() OR '' === $user->getEmail()) { if (null === $user->getEmail() || '' === $user->getEmail()) {
return $user; return $user;
} }

View File

@ -40,11 +40,6 @@ class CalendarRepository implements ObjectRepository
return $this->repository->count(['accompanyingPeriod' => $period]); return $this->repository->count(['accompanyingPeriod' => $period]);
} }
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
{
return $this->repository->createQueryBuilder($alias, $indexBy);
}
public function countByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int public function countByUser(User $user, DateTimeImmutable $from, DateTimeImmutable $to): int
{ {
return $this->buildQueryByUser($user, $from, $to) return $this->buildQueryByUser($user, $from, $to)
@ -53,6 +48,11 @@ class CalendarRepository implements ObjectRepository
->getSingleScalarResult(); ->getSingleScalarResult();
} }
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
{
return $this->repository->createQueryBuilder($alias, $indexBy);
}
public function find($id): ?Calendar public function find($id): ?Calendar
{ {
return $this->repository->find($id); return $this->repository->find($id);

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\AgentAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class AgentAggregatorTest extends AbstractAggregatorTest final class AgentAggregatorTest extends AbstractAggregatorTest
{ {
private AgentAggregator $aggregator; private AgentAggregator $aggregator;
@ -51,8 +55,7 @@ final class AgentAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder() $em->createQueryBuilder()
->select('count(cal.id)') ->select('count(cal.id)')
->from(Calendar::class, 'cal') ->from(Calendar::class, 'cal')
->join('cal.mainUser', 'caluser') ->join('cal.mainUser', 'caluser'),
,
]; ];
} }
} }

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class CancelReasonAggregatorTest extends AbstractAggregatorTest final class CancelReasonAggregatorTest extends AbstractAggregatorTest
{ {
private CancelReasonAggregator $aggregator; private CancelReasonAggregator $aggregator;
@ -51,8 +55,7 @@ final class CancelReasonAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder() $em->createQueryBuilder()
->select('count(cal.id)') ->select('count(cal.id)')
->from(Calendar::class, 'cal') ->from(Calendar::class, 'cal')
->join('cal.cancelReason', 'calcancel') ->join('cal.cancelReason', 'calcancel'),
,
]; ];
} }
} }

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\JobAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class JobAggregatorTest extends AbstractAggregatorTest final class JobAggregatorTest extends AbstractAggregatorTest
{ {
private JobAggregator $aggregator; private JobAggregator $aggregator;
@ -51,8 +55,7 @@ final class JobAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder() $em->createQueryBuilder()
->select('count(cal.id)') ->select('count(cal.id)')
->from(Calendar::class, 'cal') ->from(Calendar::class, 'cal')
->join('cal.user', 'caluser') ->join('cal.user', 'caluser'),
,
]; ];
} }
} }

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\LocationAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class LocationAggregatorTest extends AbstractAggregatorTest final class LocationAggregatorTest extends AbstractAggregatorTest
{ {
private LocationAggregator $aggregator; private LocationAggregator $aggregator;
@ -51,8 +55,7 @@ final class LocationAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder() $em->createQueryBuilder()
->select('count(cal.id)') ->select('count(cal.id)')
->from(Calendar::class, 'cal') ->from(Calendar::class, 'cal')
->join('cal.location', 'calloc') ->join('cal.location', 'calloc'),
,
]; ];
} }
} }

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class LocationTypeAggregatorTest extends AbstractAggregatorTest final class LocationTypeAggregatorTest extends AbstractAggregatorTest
{ {
private LocationTypeAggregator $aggregator; private LocationTypeAggregator $aggregator;
@ -51,8 +55,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder() $em->createQueryBuilder()
->select('count(cal.id)') ->select('count(cal.id)')
->from(Calendar::class, 'cal') ->from(Calendar::class, 'cal')
->join('cal.location', 'calloc') ->join('cal.location', 'calloc'),
,
]; ];
} }
} }

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class MonthYearAggregatorTest extends AbstractAggregatorTest final class MonthYearAggregatorTest extends AbstractAggregatorTest
{ {
private MonthYearAggregator $aggregator; private MonthYearAggregator $aggregator;
@ -50,8 +54,7 @@ final class MonthYearAggregatorTest extends AbstractAggregatorTest
return [ return [
$em->createQueryBuilder() $em->createQueryBuilder()
->select('count(cal.id)') ->select('count(cal.id)')
->from(Calendar::class, 'cal') ->from(Calendar::class, 'cal'),
,
]; ];
} }
} }

View File

@ -16,6 +16,10 @@ use Chill\CalendarBundle\Export\Aggregator\ScopeAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class ScopeAggregatorTest extends AbstractAggregatorTest final class ScopeAggregatorTest extends AbstractAggregatorTest
{ {
private ScopeAggregator $aggregator; private ScopeAggregator $aggregator;
@ -51,8 +55,7 @@ final class ScopeAggregatorTest extends AbstractAggregatorTest
$em->createQueryBuilder() $em->createQueryBuilder()
->select('count(cal.id)') ->select('count(cal.id)')
->from(Calendar::class, 'cal') ->from(Calendar::class, 'cal')
->join('cal.user', 'caluser') ->join('cal.user', 'caluser'),
,
]; ];
} }
} }

View File

@ -57,7 +57,7 @@ final class AgentFilterTest extends AbstractFilterTest
foreach ($array as $a) { foreach ($array as $a) {
$data[] = [ $data[] = [
'accepted_agents' => $a 'accepted_agents' => $a,
]; ];
} }

View File

@ -14,6 +14,7 @@ namespace Chill\CalendarBundle\Tests\Export\Filter;
use Chill\CalendarBundle\Entity\Calendar; use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Export\Filter\BetweenDatesFilter; use Chill\CalendarBundle\Export\Filter\BetweenDatesFilter;
use Chill\MainBundle\Test\Export\AbstractFilterTest; use Chill\MainBundle\Test\Export\AbstractFilterTest;
use DateTime;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/** /**
@ -46,9 +47,9 @@ final class BetweenDatesFilterTest extends AbstractFilterTest
{ {
return [ return [
[ [
'date_from' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), 'date_from' => DateTime::createFromFormat('Y-m-d', '2022-05-01'),
'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-06-01'), 'date_to' => DateTime::createFromFormat('Y-m-d', '2022-06-01'),
] ],
]; ];
} }

View File

@ -57,7 +57,7 @@ final class JobFilterTest extends AbstractFilterTest
foreach ($array as $a) { foreach ($array as $a) {
$data[] = [ $data[] = [
'job' => $a 'job' => $a,
]; ];
} }

View File

@ -57,7 +57,7 @@ final class ScopeFilterTest extends AbstractFilterTest
foreach ($array as $a) { foreach ($array as $a) {
$data[] = [ $data[] = [
'scope' => $a 'scope' => $a,
]; ];
} }

View File

@ -1,5 +1,12 @@
<?php <?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1); declare(strict_types=1);
namespace Chill\Migrations\Calendar; namespace Chill\Migrations\Calendar;
@ -12,6 +19,12 @@ use Doctrine\Migrations\AbstractMigration;
*/ */
final class Version20220921101643 extends AbstractMigration final class Version20220921101643 extends AbstractMigration
{ {
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_calendar.calendar DROP urgent');
}
public function getDescription(): string public function getDescription(): string
{ {
return 'Add urgent property to calendar entity'; return 'Add urgent property to calendar entity';
@ -21,13 +34,5 @@ final class Version20220921101643 extends AbstractMigration
{ {
// this up() migration is auto-generated, please modify it to your needs // this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_calendar.calendar ADD urgent BOOLEAN DEFAULT NULL'); $this->addSql('ALTER TABLE chill_calendar.calendar ADD urgent BOOLEAN DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE chill_calendar.calendar DROP urgent');
} }
} }