From 85504d72c29ae255ef3682996451a51648be90a3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Nov 2023 15:31:18 +0100 Subject: [PATCH 01/10] reorganize exports calendar/ refactor config yaml --- .../{ => LinkedToAcp}/CountCalendars.php | 7 +- .../LinkedToAcp/StatCalendarAvgDuration.php | 109 ++++++++++++ .../LinkedToAcp/StatCalendarSumDuration.php | 109 ++++++++++++ .../Export/LinkedToPerson/CountCalendars.php | 140 +++++++++++++++ .../StatCalendarAvgDuration.php | 4 +- .../StatCalendarSumDuration.php | 4 +- .../Resources/config/services/exports.yaml | 162 ++++++++---------- 7 files changed, 437 insertions(+), 98 deletions(-) rename src/Bundle/ChillCalendarBundle/Export/Export/{ => LinkedToAcp}/CountCalendars.php (89%) create mode 100644 src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php create mode 100644 src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php create mode 100644 src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php rename src/Bundle/ChillCalendarBundle/Export/Export/{ => LinkedToPerson}/StatCalendarAvgDuration.php (95%) rename src/Bundle/ChillCalendarBundle/Export/Export/{ => LinkedToPerson}/StatCalendarSumDuration.php (95%) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php similarity index 89% rename from src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php rename to src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php index f643eaa68..669926ef6 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\CalendarBundle\Export\Export; +namespace Chill\CalendarBundle\Export\Export\LinkedToAcp; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; @@ -17,9 +17,12 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; +use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Exception\LogicException; @@ -51,7 +54,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface public function getGroup(): string { - return 'Exports of calendar'; + return 'Exports of calendars linked to an accompanying period'; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php new file mode 100644 index 000000000..e6d27cee7 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php @@ -0,0 +1,109 @@ +getTitle(); + + return static fn ($value) => $labels[$value]; + } + + public function getQueryKeys($data): array + { + return ['export_result']; + } + + public function getResult($query, $data) + { + return $query->getQuery()->getResult(Query::HYDRATE_SCALAR); + } + + public function getTitle(): string + { + return 'Average calendar duration'; + } + + public function getType(): string + { + return Declarations::CALENDAR_TYPE; + } + + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder + { + $qb = $this->calendarRepository->createQueryBuilder('cal'); + + $qb->select('AVG(cal.endDate - cal.startDate) AS export_result'); + $qb->join('cal.accompanyingPeriod', 'acp'); + + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + + return $qb; + } + + public function requiredRole(): string + { + return AccompanyingPeriodVoter::STATS; + } + + public function supportsModifiers(): array + { + return [ + Declarations::CALENDAR_TYPE, + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php new file mode 100644 index 000000000..e16d0185c --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php @@ -0,0 +1,109 @@ +getTitle(); + + return static fn ($value) => $labels[$value]; + } + + public function getQueryKeys($data): array + { + return ['export_result']; + } + + public function getResult($query, $data) + { + return $query->getQuery()->getResult(Query::HYDRATE_SCALAR); + } + + public function getTitle(): string + { + return 'Sum of calendar durations'; + } + + public function getType(): string + { + return Declarations::CALENDAR_TYPE; + } + + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder + { + $qb = $this->calendarRepository->createQueryBuilder('cal'); + + $qb->select('SUM(cal.endDate - cal.startDate) AS export_result'); + $qb->join('cal.accompanyingPeriod', 'acp'); + + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + + return $qb; + } + + public function requiredRole(): string + { + return AccompanyingPeriodVoter::STATS; + } + + public function supportsModifiers(): array + { + return [ + Declarations::CALENDAR_TYPE, + ]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php new file mode 100644 index 000000000..8cad77f50 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php @@ -0,0 +1,140 @@ +filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; + } + + public function buildForm(FormBuilderInterface $builder) + { + // No form necessary + } + + public function getFormDefaultData(): array + { + return []; + } + + public function getAllowedFormattersTypes(): array + { + return [FormatterInterface::TYPE_TABULAR]; + } + + public function getDescription(): string + { + return 'Count calendars by various parameters.'; + } + + public function getGroup(): string + { + return 'Exports of calendars linked to a person'; + } + + public function getLabels($key, array $values, $data) + { + if ('export_result' !== $key) { + throw new LogicException("the key {$key} is not used by this export"); + } + + $labels = array_combine($values, $values); + $labels['_header'] = $this->getTitle(); + + return static fn ($value) => $labels[$value]; + } + + public function getQueryKeys($data): array + { + return ['export_result']; + } + + public function getResult($query, $data) + { + return $query->getQuery()->getResult(AbstractQuery::HYDRATE_SCALAR); + } + + public function getTitle(): string + { + return 'Count calendars'; + } + + public function getType(): string + { + return Declarations::CALENDAR_TYPE; + } + + /** + * Initiate the query. + */ + public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder + { + $centers = array_map(static fn ($el) => $el['center'], $acl); + + $qb = $this->calendarRepository->createQueryBuilder('cal'); + + $qb->select('COUNT(cal.id) AS export_result'); + $qb->leftJoin('cal.accompanyingPeriod', 'acp'); + + if ($this->filterStatsByCenters) { + $qb + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) + ' + ) + ) + ->setParameter('authorized_centers', $centers); + } + + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + + return $qb; + } + + public function requiredRole(): string + { + // which role should we give here? + return PersonVoter::STATS; + } + + public function supportsModifiers(): array + { + return [ + Declarations::CALENDAR_TYPE, + ]; + } +} + diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php similarity index 95% rename from src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php rename to src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php index b69185a17..14aa59539 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\CalendarBundle\Export\Export; +namespace Chill\CalendarBundle\Export\Export\LinkedToPerson; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; @@ -48,7 +48,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function getGroup(): string { - return 'Exports of calendar'; + return 'Exports of calendars linked to a person'; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php similarity index 95% rename from src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php rename to src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php index 8ea23014c..092286581 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php @@ -9,7 +9,7 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ -namespace Chill\CalendarBundle\Export\Export; +namespace Chill\CalendarBundle\Export\Export\LinkedToPerson; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; @@ -48,7 +48,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function getGroup(): string { - return 'Exports of calendar'; + return 'Exports of calendars linked to a person'; } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml index 3eb4bbfdc..8ab1b0d1e 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml +++ b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml @@ -1,118 +1,96 @@ services: + _defaults: + autowire: true + autoconfigure: true ## Indicators - chill.calendar.export.count_calendars: - class: Chill\CalendarBundle\Export\Export\CountCalendars - autowire: true - autoconfigure: true - tags: - - { name: chill.export, alias: count_calendars } + Chill\CalendarBundle\Export\Export\LinkedToAcp\CountCalendars: + tags: + - { name: chill.export, alias: 'count_calendars_linked_to_acp' } - chill.calendar.export.average_duration_calendars: - class: Chill\CalendarBundle\Export\Export\StatCalendarAvgDuration - autowire: true - autoconfigure: true - tags: - - { name: chill.export, alias: average_duration_calendars } + Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarAvgDuration: + tags: + - { name: chill.export, alias: 'average_duration_calendars_linked_to_acp' } - chill.calendar.export.sum_duration_calendars: - class: Chill\CalendarBundle\Export\Export\StatCalendarSumDuration - autowire: true - autoconfigure: true - tags: - - { name: chill.export, alias: sum_duration_calendars } + Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarSumDuration: + tags: + - { name: chill.export, alias: 'sum_duration_calendars_linked_to_acp' } + + Chill\CalendarBundle\Export\Export\LinkedToPerson\CountCalendars: + tags: + - { name: chill.export, alias: 'count_calendars_linked_to_person' } + + Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarAvgDuration: + tags: + - { name: chill.export, alias: 'average_duration_calendars_linked_to_person' } + + Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarSumDuration: + tags: + - { name: chill.export, alias: 'sum_duration_calendars_linked_to_person' } ## Filters - chill.calendar.export.agent_filter: - class: Chill\CalendarBundle\Export\Filter\AgentFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: agent_filter } + Chill\CalendarBundle\Export\Filter\AgentFilter: + tags: + - { name: chill.export_filter, alias: 'agent_filter' } - chill.calendar.export.job_filter: - class: Chill\CalendarBundle\Export\Filter\JobFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: job_filter } - chill.calendar.export.scope_filter: - class: Chill\CalendarBundle\Export\Filter\ScopeFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: scope_filter } + Chill\CalendarBundle\Export\Filter\JobFilter: + tags: + - { name: chill.export_filter, alias: job_filter } - chill.calendar.export.between_dates_filter: - class: Chill\CalendarBundle\Export\Filter\BetweenDatesFilter - autowire: true - autoconfigure: true - tags: - - { name: chill.export_filter, alias: between_dates_filter } - chill.calendar.export.calendar_range_filter: - class: Chill\CalendarBundle\Export\Filter\CalendarRangeFilter - autowire: true - autoconfigure: true + Chill\CalendarBundle\Export\Filter\ScopeFilter: + tags: + - { name: chill.export_filter, alias: scope_filter } + + + Chill\CalendarBundle\Export\Filter\BetweenDatesFilter: + tags: + - { name: chill.export_filter, alias: between_dates_filter } + + + Chill\CalendarBundle\Export\Filter\CalendarRangeFilter: tags: - { name: chill.export_filter, alias: calendar_range_filter } ## Aggregator - chill.calendar.export.agent_aggregator: - class: Chill\CalendarBundle\Export\Aggregator\AgentAggregator - autowire: true - autoconfigure: true - tags: - - { name: chill.export_aggregator, alias: agent_aggregator } - chill.calendar.export.job_aggregator: - class: Chill\CalendarBundle\Export\Aggregator\JobAggregator - autowire: true - autoconfigure: true - tags: - - { name: chill.export_aggregator, alias: job_aggregator } + Chill\CalendarBundle\Export\Aggregator\AgentAggregator: + tags: + - { name: chill.export_aggregator, alias: agent_aggregator } - chill.calendar.export.scope_aggregator: - class: Chill\CalendarBundle\Export\Aggregator\ScopeAggregator - autowire: true - autoconfigure: true - tags: - - { name: chill.export_aggregator, alias: scope_aggregator } - chill.calendar.export.location_type_aggregator: - class: Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator - autowire: true - autoconfigure: true - tags: - - { name: chill.export_aggregator, alias: location_type_aggregator } + Chill\CalendarBundle\Export\Aggregator\JobAggregator: + tags: + - { name: chill.export_aggregator, alias: job_aggregator } - chill.calendar.export.location_aggregator: - class: Chill\CalendarBundle\Export\Aggregator\LocationAggregator - autowire: true - autoconfigure: true - tags: - - { name: chill.export_aggregator, alias: location_aggregator } - chill.calendar.export.cancel_reason_aggregator: - class: Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator - autowire: true - autoconfigure: true - tags: - - { name: chill.export_aggregator, alias: cancel_reason_aggregator } + Chill\CalendarBundle\Export\Aggregator\ScopeAggregator: + tags: + - { name: chill.export_aggregator, alias: scope_aggregator } - chill.calendar.export.month_aggregator: - class: Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator - autowire: true - autoconfigure: true - tags: - - { name: chill.export_aggregator, alias: month_aggregator } - chill.calendar.export.urgency_aggregator: - class: Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator - autowire: true - autoconfigure: true + Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator: + tags: + - { name: chill.export_aggregator, alias: location_type_aggregator } + + + Chill\CalendarBundle\Export\Aggregator\LocationAggregator: + tags: + - { name: chill.export_aggregator, alias: location_aggregator } + + + Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator: + tags: + - { name: chill.export_aggregator, alias: cancel_reason_aggregator } + + + Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator: + tags: + - { name: chill.export_aggregator, alias: month_aggregator } + + Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator: tags: - { name: chill.export_aggregator, alias: urgency_aggregator } From 9c04212c45733017a6466639362c11a6673238b0 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Nov 2023 15:40:36 +0100 Subject: [PATCH 02/10] add center filter to calendar exports linked to acp --- .../Export/LinkedToAcp/CountCalendars.php | 20 ++++++++++++- .../LinkedToAcp/StatCalendarAvgDuration.php | 28 ++++++++++++++++++- .../LinkedToAcp/StatCalendarSumDuration.php | 27 +++++++++++++++++- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php index 669926ef6..fb2065889 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php @@ -28,9 +28,14 @@ use Symfony\Component\Validator\Exception\LogicException; class CountCalendars implements ExportInterface, GroupedExportInterface { + private readonly bool $filterStatsByCenters; + public function __construct( private readonly CalendarRepository $calendarRepository, - ) {} + ParameterBagInterface $parameterBag, + ) { + $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; + } public function buildForm(FormBuilderInterface $builder) { @@ -101,6 +106,19 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $qb->select('COUNT(cal.id) AS export_result'); $qb->leftJoin('cal.accompanyingPeriod', 'acp'); + if ($this->filterStatsByCenters) { + $qb + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) + ' + ) + ) + ->setParameter('authorized_centers', $centers); + } + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php index e6d27cee7..9e4107fcc 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php @@ -17,14 +17,25 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; +use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\FormBuilderInterface; class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { - public function __construct(private readonly CalendarRepository $calendarRepository) {} + private readonly bool $filterStatsByCenters; + + public function __construct( + private readonly CalendarRepository $calendarRepository, + ParameterBagInterface $parameterBag, + + ) { + $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; + } public function buildForm(FormBuilderInterface $builder): void { @@ -85,11 +96,26 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { + $centers = array_map(static fn ($el) => $el['center'], $acl); + $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('AVG(cal.endDate - cal.startDate) AS export_result'); $qb->join('cal.accompanyingPeriod', 'acp'); + if ($this->filterStatsByCenters) { + $qb + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) + ' + ) + ) + ->setParameter('authorized_centers', $centers); + } + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php index e16d0185c..f9e7a3150 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php @@ -17,14 +17,24 @@ use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; +use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\FormBuilderInterface; class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { - public function __construct(private readonly CalendarRepository $calendarRepository) {} + private readonly bool $filterStatsByCenters; + + public function __construct( + private readonly CalendarRepository $calendarRepository, + ParameterBagInterface $parameterBag, + ) { + $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; + } public function buildForm(FormBuilderInterface $builder): void { @@ -85,11 +95,26 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { + $centers = array_map(static fn ($el) => $el['center'], $acl); + $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('SUM(cal.endDate - cal.startDate) AS export_result'); $qb->join('cal.accompanyingPeriod', 'acp'); + if ($this->filterStatsByCenters) { + $qb + ->andWhere( + $qb->expr()->exists( + 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part + JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) + WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) + ' + ) + ) + ->setParameter('authorized_centers', $centers); + } + AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); return $qb; From fe9ce1a356f0708ce4d5c21af2e92262109e719d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Nov 2023 15:58:41 +0100 Subject: [PATCH 03/10] adjust logic for calendar exports linked to person --- .../Export/LinkedToPerson/CountCalendars.php | 21 ++++++++++--------- .../StatCalendarAvgDuration.php | 18 ++++++++++++++-- .../StatCalendarSumDuration.php | 18 ++++++++++++++-- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php index 8cad77f50..3e8ade4c7 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php @@ -104,23 +104,24 @@ class CountCalendars implements ExportInterface, GroupedExportInterface $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('COUNT(cal.id) AS export_result'); - $qb->leftJoin('cal.accompanyingPeriod', 'acp'); + $qb->leftJoin('cal.person', 'person'); if ($this->filterStatsByCenters) { $qb - ->andWhere( - $qb->expr()->exists( - 'SELECT 1 FROM '.AccompanyingPeriodParticipation::class.' acl_count_part - JOIN '.PersonCenterHistory::class.' acl_count_person_history WITH IDENTITY(acl_count_person_history.person) = IDENTITY(acl_count_part.person) - WHERE acl_count_part.accompanyingPeriod = acp.id AND acl_count_person_history.center IN (:authorized_centers) - ' + ->join('person.centerHistory', 'centerHistory') + ->where( + $qb->expr()->andX( + $qb->expr()->lte('centerHistory.startDate', 'cal.startDate'), + $qb->expr()->orX( + $qb->expr()->isNull('centerHistory.endDate'), + $qb->expr()->gt('centerHistory.endDate', 'cal.endDate') + ) ) ) - ->setParameter('authorized_centers', $centers); + ->andWhere($qb->expr()->in('centerHistory.center', ':centers')) + ->setParameter('centers', $centers); } - AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); - return $qb; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php index 14aa59539..47bccb5d4 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php @@ -88,9 +88,23 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('AVG(cal.endDate - cal.startDate) AS export_result'); - $qb->join('cal.accompanyingPeriod', 'acp'); + $qb->join('cal.person', 'person'); - AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + if ($this->filterStatsByCenters) { + $qb + ->join('person.centerHistory', 'centerHistory') + ->where( + $qb->expr()->andX( + $qb->expr()->lte('centerHistory.startDate', 'cal.startDate'), + $qb->expr()->orX( + $qb->expr()->isNull('centerHistory.endDate'), + $qb->expr()->gt('centerHistory.endDate', 'cal.endDate') + ) + ) + ) + ->andWhere($qb->expr()->in('centerHistory.center', ':centers')) + ->setParameter('centers', $centers); + } return $qb; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php index 092286581..578988e7c 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php @@ -88,9 +88,23 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('SUM(cal.endDate - cal.startDate) AS export_result'); - $qb->join('cal.accompanyingPeriod', 'acp'); + $qb->join('cal.person', 'person'); - AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb); + if ($this->filterStatsByCenters) { + $qb + ->join('person.centerHistory', 'centerHistory') + ->where( + $qb->expr()->andX( + $qb->expr()->lte('centerHistory.startDate', 'cal.startDate'), + $qb->expr()->orX( + $qb->expr()->isNull('centerHistory.endDate'), + $qb->expr()->gt('centerHistory.endDate', 'cal.endDate') + ) + ) + ) + ->andWhere($qb->expr()->in('centerHistory.center', ':centers')) + ->setParameter('centers', $centers); + } return $qb; } From e2a12968ce1e7cc06186ca999ea453ee96a35d71 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Nov 2023 16:15:24 +0100 Subject: [PATCH 04/10] add translations --- .../Export/LinkedToAcp/CountCalendars.php | 6 ++--- .../LinkedToAcp/StatCalendarAvgDuration.php | 6 ++--- .../LinkedToAcp/StatCalendarSumDuration.php | 6 ++--- .../Export/LinkedToPerson/CountCalendars.php | 6 ++--- .../StatCalendarAvgDuration.php | 6 ++--- .../StatCalendarSumDuration.php | 6 ++--- .../translations/messages.fr.yml | 25 +++++++++++++++++++ 7 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php index fb2065889..458327483 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/CountCalendars.php @@ -54,12 +54,12 @@ class CountCalendars implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Count calendars by various parameters.'; + return 'export.export.count_calendar_linked_to_acp.description'; } public function getGroup(): string { - return 'Exports of calendars linked to an accompanying period'; + return 'export.export.calendar_linked_to_acp.group'; } public function getLabels($key, array $values, $data) @@ -86,7 +86,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Count calendars'; + return 'export.export.count_calendar_linked_to_acp.title'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php index 9e4107fcc..5d5757689 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php @@ -54,12 +54,12 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Get the average of calendar duration according to various filters'; + return 'export.export.avg_duration_calendar_linked_to_acp.description'; } public function getGroup(): string { - return 'Exports of calendars linked to an accompanying period'; + return 'export.export.calendar_linked_to_acp.group'; } public function getLabels($key, array $values, $data) @@ -86,7 +86,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Average calendar duration'; + return 'export.export.avg_duration_calendar_linked_to_acp.title'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php index f9e7a3150..04dca3121 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarSumDuration.php @@ -53,12 +53,12 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Get the sum of calendar durations according to various filters'; + return 'export.export.sum_duration_calendar_linked_to_acp.description'; } public function getGroup(): string { - return 'Exports of calendars linked to an accompanying period'; + return 'export.export.calendar_linked_to_acp.group'; } public function getLabels($key, array $values, $data) @@ -85,7 +85,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Sum of calendar durations'; + return 'export.export.sum_duration_calendar_linked_to_acp.description'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php index 3e8ade4c7..e092d9cba 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php @@ -54,12 +54,12 @@ class CountCalendars implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Count calendars by various parameters.'; + return 'export.export.count_calendar_linked_to_person.description'; } public function getGroup(): string { - return 'Exports of calendars linked to a person'; + return 'export.export.calendar_linked_to_person.group'; } public function getLabels($key, array $values, $data) @@ -86,7 +86,7 @@ class CountCalendars implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Count calendars'; + return 'export.export.count_calendar_linked_to_person.title'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php index 47bccb5d4..46fc4f3b4 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php @@ -43,12 +43,12 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Get the average of calendar duration according to various filters'; + return 'export.export.stat_calendar_avg_duration_linked_to_person.description'; } public function getGroup(): string { - return 'Exports of calendars linked to a person'; + return 'export.export.calendar_linked_to_person.group'; } public function getLabels($key, array $values, $data) @@ -75,7 +75,7 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Average calendar duration'; + return 'export.export.stat_calendar_avg_duration_linked_to_person.title'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php index 578988e7c..cacfe5eb0 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php @@ -43,12 +43,12 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function getDescription(): string { - return 'Get the sum of calendar durations according to various filters'; + return 'export.export.stat_calendar_sum_duration_linked_to_person.description'; } public function getGroup(): string { - return 'Exports of calendars linked to a person'; + return 'export.export.calendar_linked_to_person.group'; } public function getLabels($key, array $values, $data) @@ -75,7 +75,7 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function getTitle(): string { - return 'Sum of calendar durations'; + return 'export.export.stat_calendar_sum_duration_linked_to_person.title'; } public function getType(): string diff --git a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml index d157683e0..80933566d 100644 --- a/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillCalendarBundle/translations/messages.fr.yml @@ -112,6 +112,31 @@ Group calendars by month and year: Grouper les rendez-vous par mois et année Group calendars by urgency: Grouper les rendez-vous par urgent ou non export: + export: + calendar_linked_to_person: + group: Exports des rendez-vous liés à un usager + calendar_linked_to_acp: + group: Exports des rendez-vous liés à un parcours + stat_calendar_sum_duration_linked_to_person: + title: Somme de la durée des rendez-vous + description: Additionne la durée des rendez-vous en fonction de différents paramètres. + stat_calendar_avg_duration_linked_to_person: + title: Moyenne de la durée des rendez-vous + description: Moyenne de la durée des rendez-vous en fonction de différents paramètres. + count_calendar_linked_to_person: + title: Nombre des rendez-vous + description: Compte le nombre des rendez-vous enregistrés et liés à un usager en fonction de différents paramètres. + count_calendar_linked_to_acp: + title: Nombre des rendez-vous + description: Compte le nombre des rendez-vous enregistrés et liées à un parcours en fonction de différents paramètres. + avg_duration_calendar_linked_to_acp: + title: Moyenne de la durée des rendez-vous + description: Moyenne de la durée des rendez-vous en fonction de différents paramètres. + sum_duration_calendar_linked_to_acp: + title: Somme de la durée des rendez-vous + description: Additionne la durée des rendez-vous en fonction de différents paramètres. + + aggregator.calendar: agent_job: Group calendars by agent job: Grouper les rendez-vous par métier de l'agent From 27bf2893d003263c938eac0036db3a50c493e549 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Nov 2023 16:19:43 +0100 Subject: [PATCH 05/10] add missing variables to two exports --- .../LinkedToPerson/StatCalendarAvgDuration.php | 12 +++++++++++- .../LinkedToPerson/StatCalendarSumDuration.php | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php index 46fc4f3b4..2f06c4db2 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php @@ -20,11 +20,19 @@ use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\FormBuilderInterface; class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface { - public function __construct(private readonly CalendarRepository $calendarRepository) {} + private readonly bool $filterStatsByCenters; + + public function __construct( + private readonly CalendarRepository $calendarRepository, + ParameterBagInterface $parameterBag, + ) { + $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; + } public function buildForm(FormBuilderInterface $builder): void { @@ -85,6 +93,8 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { + $centers = array_map(static fn ($el) => $el['center'], $acl); + $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('AVG(cal.endDate - cal.startDate) AS export_result'); diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php index cacfe5eb0..094125e3d 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php @@ -20,11 +20,20 @@ use Chill\MainBundle\Export\GroupedExportInterface; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\FormBuilderInterface; class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface { - public function __construct(private readonly CalendarRepository $calendarRepository) {} + private readonly bool $filterStatsByCenters; + + public function __construct( + private readonly CalendarRepository $calendarRepository, + ParameterBagInterface $parameterBag, + ) { + $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; + + } public function buildForm(FormBuilderInterface $builder): void { @@ -85,6 +94,8 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder { + $centers = array_map(static fn ($el) => $el['center'], $acl); + $qb = $this->calendarRepository->createQueryBuilder('cal'); $qb->select('SUM(cal.endDate - cal.startDate) AS export_result'); From b317daf779cdb3eaba3211bf86e5da089272fb90 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Nov 2023 16:20:10 +0100 Subject: [PATCH 06/10] php cs fixes --- .../Export/Export/LinkedToAcp/StatCalendarAvgDuration.php | 1 - .../Export/Export/LinkedToPerson/CountCalendars.php | 4 ---- .../Export/Export/LinkedToPerson/StatCalendarAvgDuration.php | 1 - .../Export/Export/LinkedToPerson/StatCalendarSumDuration.php | 2 -- 4 files changed, 8 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php index 5d5757689..e6287fcb5 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToAcp/StatCalendarAvgDuration.php @@ -32,7 +32,6 @@ class StatCalendarAvgDuration implements ExportInterface, GroupedExportInterface public function __construct( private readonly CalendarRepository $calendarRepository, ParameterBagInterface $parameterBag, - ) { $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; } diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php index e092d9cba..a0822f3df 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/CountCalendars.php @@ -13,12 +13,9 @@ namespace Chill\CalendarBundle\Export\Export\LinkedToPerson; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; -use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; -use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; -use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Security\Authorization\PersonVoter; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\QueryBuilder; @@ -138,4 +135,3 @@ class CountCalendars implements ExportInterface, GroupedExportInterface ]; } } - diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php index 2f06c4db2..a0263dd39 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarAvgDuration.php @@ -13,7 +13,6 @@ namespace Chill\CalendarBundle\Export\Export\LinkedToPerson; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; -use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; diff --git a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php index 094125e3d..9e54a388a 100644 --- a/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php +++ b/src/Bundle/ChillCalendarBundle/Export/Export/LinkedToPerson/StatCalendarSumDuration.php @@ -13,7 +13,6 @@ namespace Chill\CalendarBundle\Export\Export\LinkedToPerson; use Chill\CalendarBundle\Export\Declarations; use Chill\CalendarBundle\Repository\CalendarRepository; -use Chill\MainBundle\Export\AccompanyingCourseExportHelper; use Chill\MainBundle\Export\ExportInterface; use Chill\MainBundle\Export\FormatterInterface; use Chill\MainBundle\Export\GroupedExportInterface; @@ -32,7 +31,6 @@ class StatCalendarSumDuration implements ExportInterface, GroupedExportInterface ParameterBagInterface $parameterBag, ) { $this->filterStatsByCenters = $parameterBag->get('chill_main')['acl']['filter_stats_by_center']; - } public function buildForm(FormBuilderInterface $builder): void From b0171e30939c6a0e5b4a68ce2272774b611a704f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Nov 2023 16:34:08 +0100 Subject: [PATCH 07/10] Add tests for new exports calendar --- .../Export/Export/CountCalendarsTest.php | 55 +++++++++++++++++++ .../Export/StatCalendarAvgDurationTest.php | 55 +++++++++++++++++++ .../Export/StatCalendarSumDurationTest.php | 55 +++++++++++++++++++ 3 files changed, 165 insertions(+) create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Export/CountCalendarsTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarAvgDurationTest.php create mode 100644 src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarSumDurationTest.php diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/CountCalendarsTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/CountCalendarsTest.php new file mode 100644 index 000000000..73ef2817c --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/CountCalendarsTest.php @@ -0,0 +1,55 @@ +get(CalendarRepository::class); + + yield new CountCalendarsLinkedToAcp($repository, $this->getParameters(true)); + yield new CountCalendarsLinkedToAcp($repository, $this->getParameters(false)); + + yield new CountCalendarsLinkedToPerson($repository, $this->getParameters(true)); + yield new CountCalendarsLinkedToPerson($repository, $this->getParameters(false)); + + } + + /** + * @inheritDoc + */ + public function getFormData() + { + return []; + } + + /** + * @inheritDoc + */ + public function getModifiersCombination() + { + return [ + [ + Declarations::CALENDAR_TYPE, + ]]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarAvgDurationTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarAvgDurationTest.php new file mode 100644 index 000000000..46b4e5226 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarAvgDurationTest.php @@ -0,0 +1,55 @@ +get(CalendarRepository::class); + + yield new StatCalendarAvgDurationLinkedToAcp($repository, $this->getParameters(true)); + yield new StatCalendarAvgDurationLinkedToAcp($repository, $this->getParameters(false)); + + yield new StatCalendarAvgDurationLinkedToPerson($repository, $this->getParameters(true)); + yield new StatCalendarAvgDurationLinkedToPerson($repository, $this->getParameters(false)); + + } + + /** + * @inheritDoc + */ + public function getFormData() + { + return []; + } + + /** + * @inheritDoc + */ + public function getModifiersCombination() + { + return [ + [ + Declarations::CALENDAR_TYPE, + ]]; + } +} diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarSumDurationTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarSumDurationTest.php new file mode 100644 index 000000000..d77f384c0 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarSumDurationTest.php @@ -0,0 +1,55 @@ +get(CalendarRepository::class); + + yield new StatCalendarSumDurationLinkedToAcp($repository, $this->getParameters(true)); + yield new StatCalendarSumDurationLinkedToAcp($repository, $this->getParameters(false)); + + yield new StatCalendarSumDurationLinkedToPerson($repository, $this->getParameters(true)); + yield new StatCalendarSumDurationLinkedToPerson($repository, $this->getParameters(false)); + + } + + /** + * @inheritDoc + */ + public function getFormData() + { + return []; + } + + /** + * @inheritDoc + */ + public function getModifiersCombination() + { + return [ + [ + Declarations::CALENDAR_TYPE, + ]]; + } +} From bc638e5eb9446f092840084f45b2bdddd9461d4b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Nov 2023 16:38:57 +0100 Subject: [PATCH 08/10] style fixes for tests --- .../Export/Export/CountCalendarsTest.php | 20 +++++++++---------- .../Export/StatCalendarAvgDurationTest.php | 20 +++++++++---------- .../Export/StatCalendarSumDurationTest.php | 20 +++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/CountCalendarsTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/CountCalendarsTest.php index 73ef2817c..3b351ffbe 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/CountCalendarsTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/CountCalendarsTest.php @@ -1,5 +1,14 @@ get(CalendarRepository::class); @@ -31,20 +38,13 @@ class CountCalendarsTest extends AbstractExportTest yield new CountCalendarsLinkedToPerson($repository, $this->getParameters(true)); yield new CountCalendarsLinkedToPerson($repository, $this->getParameters(false)); - } - /** - * @inheritDoc - */ public function getFormData() { return []; } - /** - * @inheritDoc - */ public function getModifiersCombination() { return [ diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarAvgDurationTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarAvgDurationTest.php index 46b4e5226..f4fb35274 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarAvgDurationTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarAvgDurationTest.php @@ -1,5 +1,14 @@ get(CalendarRepository::class); @@ -31,20 +38,13 @@ class StatCalendarAvgDurationTest extends AbstractExportTest yield new StatCalendarAvgDurationLinkedToPerson($repository, $this->getParameters(true)); yield new StatCalendarAvgDurationLinkedToPerson($repository, $this->getParameters(false)); - } - /** - * @inheritDoc - */ public function getFormData() { return []; } - /** - * @inheritDoc - */ public function getModifiersCombination() { return [ diff --git a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarSumDurationTest.php b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarSumDurationTest.php index d77f384c0..c91d01628 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarSumDurationTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Export/Export/StatCalendarSumDurationTest.php @@ -1,5 +1,14 @@ get(CalendarRepository::class); @@ -31,20 +38,13 @@ class StatCalendarSumDurationTest extends AbstractExportTest yield new StatCalendarSumDurationLinkedToPerson($repository, $this->getParameters(true)); yield new StatCalendarSumDurationLinkedToPerson($repository, $this->getParameters(false)); - } - /** - * @inheritDoc - */ public function getFormData() { return []; } - /** - * @inheritDoc - */ public function getModifiersCombination() { return [ From a7141ef771d1285291207bd61a3de244a62cf03e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Nov 2023 10:43:47 +0100 Subject: [PATCH 09/10] fix export.yaml file: remove quotes --- .../Resources/config/services/exports.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml index 8ab1b0d1e..d8e47b2c4 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml +++ b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml @@ -6,33 +6,33 @@ services: ## Indicators Chill\CalendarBundle\Export\Export\LinkedToAcp\CountCalendars: tags: - - { name: chill.export, alias: 'count_calendars_linked_to_acp' } + - { name: chill.export, alias: count_calendars_linked_to_acp } Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarAvgDuration: tags: - - { name: chill.export, alias: 'average_duration_calendars_linked_to_acp' } + - { name: chill.export, alias: average_duration_calendars_linked_to_acp } Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarSumDuration: tags: - - { name: chill.export, alias: 'sum_duration_calendars_linked_to_acp' } + - { name: chill.export, alias: sum_duration_calendars_linked_to_acp } Chill\CalendarBundle\Export\Export\LinkedToPerson\CountCalendars: tags: - - { name: chill.export, alias: 'count_calendars_linked_to_person' } + - { name: chill.export, alias: count_calendars_linked_to_person } Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarAvgDuration: tags: - - { name: chill.export, alias: 'average_duration_calendars_linked_to_person' } + - { name: chill.export, alias: average_duration_calendars_linked_to_person } Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarSumDuration: tags: - - { name: chill.export, alias: 'sum_duration_calendars_linked_to_person' } + - { name: chill.export, alias: sum_duration_calendars_linked_to_person } ## Filters Chill\CalendarBundle\Export\Filter\AgentFilter: tags: - - { name: chill.export_filter, alias: 'agent_filter' } + - { name: chill.export_filter, alias: agent_filter } Chill\CalendarBundle\Export\Filter\JobFilter: From 792ad394c8da20046f2f417088141407488cab1e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Nov 2023 11:14:38 +0100 Subject: [PATCH 10/10] Format yaml file back to they way it was before --- .../Resources/config/services/exports.yaml | 151 +++++++++++------- 1 file changed, 97 insertions(+), 54 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml index d8e47b2c4..57a4e8082 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml +++ b/src/Bundle/ChillCalendarBundle/Resources/config/services/exports.yaml @@ -1,96 +1,139 @@ services: - _defaults: + + ## Indicators + chill.calendar.export.count_calendars_linked_to_acp: + class: Chill\CalendarBundle\Export\Export\LinkedToAcp\CountCalendars autowire: true autoconfigure: true - - ## Indicators - Chill\CalendarBundle\Export\Export\LinkedToAcp\CountCalendars: tags: - - { name: chill.export, alias: count_calendars_linked_to_acp } + - { name: chill.export, alias: count_calendars_linked_to_acp } - Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarAvgDuration: + chill.calendar.export.average_duration_calendars_linked_to_acp: + class: Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarAvgDuration + autowire: true + autoconfigure: true tags: - - { name: chill.export, alias: average_duration_calendars_linked_to_acp } + - { name: chill.export, alias: average_duration_calendars_linked_to_acp } - Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarSumDuration: + chill.calendar.export.sum_duration_calendars_linked_to_acp: + class: Chill\CalendarBundle\Export\Export\LinkedToAcp\StatCalendarSumDuration + autowire: true + autoconfigure: true tags: - - { name: chill.export, alias: sum_duration_calendars_linked_to_acp } + - { name: chill.export, alias: sum_duration_calendars_linked_to_acp } - Chill\CalendarBundle\Export\Export\LinkedToPerson\CountCalendars: + chill.calendar.export.count_calendars_linked_to_person: + class: Chill\CalendarBundle\Export\Export\LinkedToPerson\CountCalendars + autowire: true + autoconfigure: true tags: - { name: chill.export, alias: count_calendars_linked_to_person } - Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarAvgDuration: + chill.calendar.export.average_duration_calendars_linked_to_person: + class: Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarAvgDuration + autowire: true + autoconfigure: true tags: - { name: chill.export, alias: average_duration_calendars_linked_to_person } - Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarSumDuration: + chill.calendar.export.sum_duration_calendars_linked_to_person: + class: Chill\CalendarBundle\Export\Export\LinkedToPerson\StatCalendarSumDuration + autowire: true + autoconfigure: true tags: - { name: chill.export, alias: sum_duration_calendars_linked_to_person } - ## Filters + ## Filters - Chill\CalendarBundle\Export\Filter\AgentFilter: + chill.calendar.export.agent_filter: + class: Chill\CalendarBundle\Export\Filter\AgentFilter + autowire: true + autoconfigure: true tags: - - { name: chill.export_filter, alias: agent_filter } + - { name: chill.export_filter, alias: agent_filter } - - Chill\CalendarBundle\Export\Filter\JobFilter: + chill.calendar.export.job_filter: + class: Chill\CalendarBundle\Export\Filter\JobFilter + autowire: true + autoconfigure: true tags: - - { name: chill.export_filter, alias: job_filter } + - { name: chill.export_filter, alias: job_filter } - - Chill\CalendarBundle\Export\Filter\ScopeFilter: + chill.calendar.export.scope_filter: + class: Chill\CalendarBundle\Export\Filter\ScopeFilter + autowire: true + autoconfigure: true tags: - - { name: chill.export_filter, alias: scope_filter } + - { name: chill.export_filter, alias: scope_filter } - - Chill\CalendarBundle\Export\Filter\BetweenDatesFilter: + chill.calendar.export.between_dates_filter: + class: Chill\CalendarBundle\Export\Filter\BetweenDatesFilter + autowire: true + autoconfigure: true tags: - - { name: chill.export_filter, alias: between_dates_filter } + - { name: chill.export_filter, alias: between_dates_filter } - - Chill\CalendarBundle\Export\Filter\CalendarRangeFilter: - tags: - - { name: chill.export_filter, alias: calendar_range_filter } - - ## Aggregator - - - Chill\CalendarBundle\Export\Aggregator\AgentAggregator: + chill.calendar.export.calendar_range_filter: + class: Chill\CalendarBundle\Export\Filter\CalendarRangeFilter + autowire: true + autoconfigure: true tags: - - { name: chill.export_aggregator, alias: agent_aggregator } + - { name: chill.export_filter, alias: calendar_range_filter } + ## Aggregator - Chill\CalendarBundle\Export\Aggregator\JobAggregator: + chill.calendar.export.agent_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\AgentAggregator + autowire: true + autoconfigure: true tags: - - { name: chill.export_aggregator, alias: job_aggregator } + - { name: chill.export_aggregator, alias: agent_aggregator } - - Chill\CalendarBundle\Export\Aggregator\ScopeAggregator: + chill.calendar.export.job_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\JobAggregator + autowire: true + autoconfigure: true tags: - - { name: chill.export_aggregator, alias: scope_aggregator } + - { name: chill.export_aggregator, alias: job_aggregator } - - Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator: + chill.calendar.export.scope_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\ScopeAggregator + autowire: true + autoconfigure: true tags: - - { name: chill.export_aggregator, alias: location_type_aggregator } + - { name: chill.export_aggregator, alias: scope_aggregator } - - Chill\CalendarBundle\Export\Aggregator\LocationAggregator: + chill.calendar.export.location_type_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\LocationTypeAggregator + autowire: true + autoconfigure: true tags: - - { name: chill.export_aggregator, alias: location_aggregator } + - { name: chill.export_aggregator, alias: location_type_aggregator } - - Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator: + chill.calendar.export.location_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\LocationAggregator + autowire: true + autoconfigure: true tags: - - { name: chill.export_aggregator, alias: cancel_reason_aggregator } + - { name: chill.export_aggregator, alias: location_aggregator } - - Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator: + chill.calendar.export.cancel_reason_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\CancelReasonAggregator + autowire: true + autoconfigure: true tags: - - { name: chill.export_aggregator, alias: month_aggregator } + - { name: chill.export_aggregator, alias: cancel_reason_aggregator } - Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator: - tags: - - { name: chill.export_aggregator, alias: urgency_aggregator } + chill.calendar.export.month_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\MonthYearAggregator + autowire: true + autoconfigure: true + tags: + - { name: chill.export_aggregator, alias: month_aggregator } + + chill.calendar.export.urgency_aggregator: + class: Chill\CalendarBundle\Export\Aggregator\UrgencyAggregator + autowire: true + autoconfigure: true + tags: + - { name: chill.export_aggregator, alias: urgency_aggregator }