leftJoin('cal.mainUser', "{$p}_user") ->leftJoin( UserJobHistory::class, "{$p}_history", Join::WITH, $qb->expr()->eq("{$p}_history.user", "{$p}_user") ) // job_at based on cal.startDate ->andWhere( $qb->expr()->andX( $qb->expr()->lte("{$p}_history.startDate", 'cal.startDate'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), $qb->expr()->gt("{$p}_history.endDate", 'cal.startDate') ) ) ) ->addSelect("IDENTITY({$p}_history.job) AS {$p}_select") ->addGroupBy("{$p}_select"); } public function applyOn(): string { return Declarations::CALENDAR_TYPE; } public function buildForm(FormBuilderInterface $builder) {} public function getFormDefaultData(): array { return []; } public function getLabels($key, array $values, $data): \Closure { return function ($value): string { if ('_header' === $value) { return 'Job'; } if (null === $value || '' === $value) { return ''; } if (null === $j = $this->jobRepository->find($value)) { return ''; } return $this->translatableStringHelper->localize( $j->getLabel() ); }; } public function getQueryKeys($data): array { return [self::PREFIX.'_select']; } public function getTitle(): string { return 'export.aggregator.calendar.agent_job.Group calendars by agent job'; } }