mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
[Activity][Export] Fixed: use leftJoin on aggregators
This commit is contained in:
parent
4fe4f6a877
commit
b9d4b5650b
@ -41,18 +41,11 @@ class BySocialActionAggregator implements AggregatorInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
if (!in_array('actsocialaction', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.socialActions', 'actsocialaction');
|
$qb->leftJoin('activity.socialActions', 'actsocialaction');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('actsocialaction.id AS socialaction_aggregator');
|
$qb->addSelect('actsocialaction.id AS socialaction_aggregator');
|
||||||
|
$qb->addGroupBy('socialaction_aggregator');
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy('socialaction_aggregator');
|
|
||||||
} else {
|
|
||||||
$qb->groupBy('socialaction_aggregator');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -72,6 +65,10 @@ class BySocialActionAggregator implements AggregatorInterface
|
|||||||
return 'Social action';
|
return 'Social action';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$sa = $this->actionRepository->find($value);
|
$sa = $this->actionRepository->find($value);
|
||||||
|
|
||||||
return $this->actionRender->renderString($sa, []);
|
return $this->actionRender->renderString($sa, []);
|
||||||
|
@ -41,18 +41,11 @@ class BySocialIssueAggregator implements AggregatorInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
if (!in_array('actsocialissue', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.socialIssues', 'actsocialissue');
|
$qb->leftJoin('activity.socialIssues', 'actsocialissue');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('actsocialissue.id AS socialissue_aggregator');
|
$qb->addSelect('actsocialissue.id AS socialissue_aggregator');
|
||||||
|
$qb->addGroupBy('socialissue_aggregator');
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy('socialissue_aggregator');
|
|
||||||
} else {
|
|
||||||
$qb->groupBy('socialissue_aggregator');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -72,6 +65,10 @@ class BySocialIssueAggregator implements AggregatorInterface
|
|||||||
return 'Social issues';
|
return 'Social issues';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$i = $this->issueRepository->find($value);
|
$i = $this->issueRepository->find($value);
|
||||||
|
|
||||||
return $this->issueRender->renderString($i, []);
|
return $this->issueRender->renderString($i, []);
|
||||||
|
@ -41,18 +41,11 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('acttparty', $qb->getAllAliases(), true)) {
|
if (!in_array('acttparty', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.thirdParties', 'acttparty');
|
$qb->leftJoin('activity.thirdParties', 'acttparty');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('acttparty.id AS thirdparty_aggregator');
|
$qb->addSelect('acttparty.id AS thirdparty_aggregator');
|
||||||
|
$qb->addGroupBy('thirdparty_aggregator');
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy('thirdparty_aggregator');
|
|
||||||
} else {
|
|
||||||
$qb->groupBy('thirdparty_aggregator');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -72,6 +65,10 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
|||||||
return 'Accepted thirdparty';
|
return 'Accepted thirdparty';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$tp = $this->thirdPartyRepository->find($value);
|
$tp = $this->thirdPartyRepository->find($value);
|
||||||
|
|
||||||
return $this->thirdPartyRender->renderString($tp, []);
|
return $this->thirdPartyRender->renderString($tp, []);
|
||||||
|
@ -41,18 +41,11 @@ class ByUserAggregator implements AggregatorInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actusers', $qb->getAllAliases(), true)) {
|
if (!in_array('actusers', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.users', 'actusers');
|
$qb->leftJoin('activity.users', 'actusers');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('actusers.id AS users_aggregator');
|
$qb->addSelect('actusers.id AS users_aggregator');
|
||||||
|
$qb->addGroupBy('users_aggregator');
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy('users_aggregator');
|
|
||||||
} else {
|
|
||||||
$qb->groupBy('users_aggregator');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -72,6 +65,10 @@ class ByUserAggregator implements AggregatorInterface
|
|||||||
return 'Accepted users';
|
return 'Accepted users';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$u = $this->userRepository->find($value);
|
$u = $this->userRepository->find($value);
|
||||||
|
|
||||||
return $this->userRender->renderString($u, []);
|
return $this->userRender->renderString($u, []);
|
||||||
|
@ -49,11 +49,11 @@ class DateAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
switch ($data['frequency']) {
|
switch ($data['frequency']) {
|
||||||
case 'month':
|
case 'month':
|
||||||
$fmt = 'MM';
|
$fmt = 'YYYY-MM';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'week':
|
case 'week':
|
||||||
$fmt = 'IW';
|
$fmt = 'YYYY-IW';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'year':
|
case 'year':
|
||||||
@ -65,22 +65,8 @@ class DateAggregator implements AggregatorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect(sprintf("TO_CHAR(activity.date, '%s') AS date_aggregator", $fmt));
|
$qb->addSelect(sprintf("TO_CHAR(activity.date, '%s') AS date_aggregator", $fmt));
|
||||||
|
$qb->addGroupBy('date_aggregator');
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
$qb->addOrderBy('date_aggregator', $order);
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy('date_aggregator');
|
|
||||||
} else {
|
|
||||||
$qb->groupBy('date_aggregator');
|
|
||||||
}
|
|
||||||
|
|
||||||
$orderBy = $qb->getDQLPart('orderBy');
|
|
||||||
|
|
||||||
if (!empty($orderBy)) {
|
|
||||||
$qb->addOrderBy('date_aggregator', $order);
|
|
||||||
} else {
|
|
||||||
$qb->orderBy('date_aggregator', $order);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -106,15 +92,12 @@ class DateAggregator implements AggregatorInterface
|
|||||||
return 'by ' . $data['frequency'];
|
return 'by ' . $data['frequency'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
switch ($data['frequency']) {
|
switch ($data['frequency']) {
|
||||||
case 'month':
|
case 'month':
|
||||||
$month = DateTime::createFromFormat('!m', $value);
|
|
||||||
|
|
||||||
return sprintf(
|
|
||||||
'%02d (%s)',
|
|
||||||
$value,
|
|
||||||
$month->format('M')
|
|
||||||
);
|
|
||||||
|
|
||||||
case 'week':
|
case 'week':
|
||||||
//return $this->translator->trans('for week') .' '. $value ;
|
//return $this->translator->trans('for week') .' '. $value ;
|
||||||
|
@ -41,18 +41,11 @@ class LocationTypeAggregator implements AggregatorInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actloc', $qb->getAllAliases(), true)) {
|
if (!in_array('actloc', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.location', 'actloc');
|
$qb->leftJoin('activity.location', 'actloc');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('IDENTITY(actloc.locationType) AS locationtype_aggregator');
|
$qb->addSelect('IDENTITY(actloc.locationType) AS locationtype_aggregator');
|
||||||
|
$qb->addGroupBy('locationtype_aggregator');
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy('locationtype_aggregator');
|
|
||||||
} else {
|
|
||||||
$qb->groupBy('locationtype_aggregator');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -72,6 +65,10 @@ class LocationTypeAggregator implements AggregatorInterface
|
|||||||
return 'Accepted locationtype';
|
return 'Accepted locationtype';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$lt = $this->locationTypeRepository->find($value);
|
$lt = $this->locationTypeRepository->find($value);
|
||||||
|
|
||||||
return $this->translatableStringHelper->localize(
|
return $this->translatableStringHelper->localize(
|
||||||
|
@ -41,18 +41,11 @@ class UserScopeAggregator implements AggregatorInterface
|
|||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actuser', $qb->getAllAliases(), true)) {
|
if (!in_array('actuser', $qb->getAllAliases(), true)) {
|
||||||
$qb->join('activity.user', 'actuser');
|
$qb->leftJoin('activity.user', 'actuser');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('IDENTITY(actuser.mainScope) AS userscope_aggregator');
|
$qb->addSelect('IDENTITY(actuser.mainScope) AS userscope_aggregator');
|
||||||
|
$qb->addGroupBy('userscope_aggregator');
|
||||||
$groupBy = $qb->getDQLPart('groupBy');
|
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy('userscope_aggregator');
|
|
||||||
} else {
|
|
||||||
$qb->groupBy('userscope_aggregator');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -72,6 +65,10 @@ class UserScopeAggregator implements AggregatorInterface
|
|||||||
return 'Scope';
|
return 'Scope';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$s = $this->scopeRepository->find($value);
|
$s = $this->scopeRepository->find($value);
|
||||||
|
|
||||||
return $this->translatableStringHelper->localize(
|
return $this->translatableStringHelper->localize(
|
||||||
|
@ -49,14 +49,7 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY));
|
$qb->addSelect(sprintf('IDENTITY(activity.activityType) AS %s', self::KEY));
|
||||||
|
$qb->addGroupBy(self::KEY);
|
||||||
$groupby = $qb->getDQLPart('groupBy');
|
|
||||||
|
|
||||||
if (!empty($groupBy)) {
|
|
||||||
$qb->addGroupBy(self::KEY);
|
|
||||||
} else {
|
|
||||||
$qb->groupBy(self::KEY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -79,6 +72,10 @@ class ActivityTypeAggregator implements AggregatorInterface
|
|||||||
return 'Activity type';
|
return 'Activity type';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$t = $this->activityTypeRepository->find($value);
|
$t = $this->activityTypeRepository->find($value);
|
||||||
|
|
||||||
return $this->translatableStringHelper->localize($t->getName());
|
return $this->translatableStringHelper->localize($t->getName());
|
||||||
|
@ -61,14 +61,15 @@ class ActivityUserAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getLabels($key, $values, $data): Closure
|
public function getLabels($key, $values, $data): Closure
|
||||||
{
|
{
|
||||||
// preload users at once
|
return function ($value) {
|
||||||
$this->userRepository->findBy(['id' => $values]);
|
|
||||||
|
|
||||||
return function ($value) {
|
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return 'Activity user';
|
return 'Activity user';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null === $value) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$u = $this->userRepository->find($value);
|
$u = $this->userRepository->find($value);
|
||||||
|
|
||||||
return $this->userRender->renderString($u, []);
|
return $this->userRender->renderString($u, []);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user