chill-bundles#25: replace ChillDateType by PickRollingDateType

batch/serial replacing
untested
This commit is contained in:
2022-11-14 15:38:14 +01:00
parent 1f3dd00d81
commit 68bfb082fc
31 changed files with 512 additions and 251 deletions

View File

@@ -15,12 +15,13 @@ use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\GeographicalUnit;
use Chill\MainBundle\Entity\GeographicalUnitLayer;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Repository\GeographicalUnitLayerRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -34,12 +35,16 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
private TranslatableStringHelperInterface $translatableStringHelper;
private RollingDateConverterInterface $rollingDateConverter;
public function __construct(
GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository,
TranslatableStringHelperInterface $translatableStringHelper
TranslatableStringHelperInterface $translatableStringHelper,
RollingDateConverterInterface $rollingDateConverter
) {
$this->geographicalUnitLayerRepository = $geographicalUnitLayerRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -62,7 +67,9 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
)
);
$qb->setParameter('acp_geog_aggregator_date', $data['date_calc']);
$qb->setParameter('acp_geog_aggregator_date',
$this->rollingDateConverter->convert($data['date_calc'])
);
}
// link between location history and person
@@ -81,7 +88,9 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
)
);
$qb->setParameter('acp_geog_aggregator_date', $data['date_calc']);
$qb->setParameter('acp_geog_aggregator_date',
$this->rollingDateConverter->convert($data['date_calc'])
);
}
// we finally find an address
@@ -122,11 +131,10 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('date_calc', ChillDateType::class, [
->add('date_calc', PickRollingDateType::class, [
'label' => 'Compute geographical location at date',
'required' => true,
'data' => new DateTimeImmutable('today'),
'input' => 'datetime_immutable',
'data' => new RollingDate(RollingDate::T_TODAY),
])
->add('level', EntityType::class, [
'label' => 'Geographical layer',

View File

@@ -12,11 +12,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Repository\UserRepository;
use Chill\MainBundle\Templating\Entity\UserRender;
use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
@@ -30,12 +31,16 @@ final class ReferrerAggregator implements AggregatorInterface
private UserRepository $userRepository;
private RollingDateConverterInterface $rollingDateConverter;
public function __construct(
UserRepository $userRepository,
UserRender $userRender
UserRender $userRender,
RollingDateConverterInterface $rollingDateConverter
) {
$this->userRepository = $userRepository;
$this->userRender = $userRender;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -61,7 +66,9 @@ final class ReferrerAggregator implements AggregatorInterface
)
)
)
->setParameter(self::P, $data['date_calc']);
->setParameter(self::P,
$this->rollingDateConverter->convert($data['date_calc'])
);
}
public function applyOn(): string
@@ -72,9 +79,8 @@ final class ReferrerAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder
->add('date_calc', ChillDateType::class, [
'input' => 'datetime_immutable',
'data' => new DateTimeImmutable('now'),
->add('date_calc', PickRollingDateType::class, [
'data' => new RollingDate(RollingDate::T_TODAY),
'label' => 'export.aggregator.course.by_referrer.Computation date for referrer',
'required' => true,
]);

View File

@@ -12,11 +12,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\PickRollingDateType;
use Chill\MainBundle\Service\RollingDate\RollingDate;
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Chill\PersonBundle\Export\Declarations;
use DateTimeImmutable;
use Doctrine\ORM\QueryBuilder;
use LogicException;
use Symfony\Component\Form\FormBuilderInterface;
@@ -29,12 +30,16 @@ class ReferrerScopeAggregator implements AggregatorInterface
private TranslatableStringHelperInterface $translatableStringHelper;
private RollingDateConverterInterface $rollingDateConverter;
public function __construct(
ScopeRepositoryInterface $scopeRepository,
TranslatableStringHelperInterface $translatableStringHelper
TranslatableStringHelperInterface $translatableStringHelper,
RollingDateConverterInterface $rollingDateConverter
) {
$this->scopeRepository = $scopeRepository;
$this->translatableStringHelper = $translatableStringHelper;
$this->rollingDateConverter = $rollingDateConverter;
}
public function addRole(): ?string
@@ -64,7 +69,9 @@ class ReferrerScopeAggregator implements AggregatorInterface
)
)
)
->setParameter($dateCalc, $data['date_calc']);
->setParameter($dateCalc,
$this->rollingDateConverter->convert($data['date_calc'])
);
// add groups
$qb
@@ -79,9 +86,8 @@ class ReferrerScopeAggregator implements AggregatorInterface
public function buildForm(FormBuilderInterface $builder)
{
$builder->add('date_calc', ChillDateType::class, [
'input' => 'datetime_immutable',
'data' => new DateTimeImmutable('now'),
$builder->add('date_calc', PickRollingDateType::class, [
'data' => new RollingDate(RollingDate::T_TODAY),
'label' => 'export.aggregator.course.by_user_scope.Computation date for referrer',
'required' => true,
]);