Skip to content

Commit

Permalink
fix: ambiguous column aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio committed Oct 24, 2024
1 parent cd12a8a commit fa527ad
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public function generate(): void

return [
$indicator->label() => [
$reportQuery::build($this->report)
->distinct('id')
->count('id'),
$reportQuery::aggregate($this->report),
],
];
}),
Expand Down
5 changes: 5 additions & 0 deletions app/Reports/Queries/Child/C21.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public static function dateColumn(): string
return 'interventionable_individual_services.date';
}

public static function aggregateByColumn(): string
{
return 'interventions.id';
}

public static function columns(): array
{
return [
Expand Down
5 changes: 5 additions & 0 deletions app/Reports/Queries/General/G11.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public static function dateColumn(): string
return 'interventionable_individual_services.date';
}

public static function aggregateByColumn(): string
{
return 'interventions.id';
}

public static function columns(): array
{
return [
Expand Down
5 changes: 5 additions & 0 deletions app/Reports/Queries/General/G27.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public static function dateColumn(): string
return 'interventionable_individual_services.date';
}

public static function aggregateByColumn(): string
{
return 'interventions.id';
}

public static function columns(): array
{
return [
Expand Down
5 changes: 5 additions & 0 deletions app/Reports/Queries/General/G28.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public static function dateColumn(): string
return 'interventionable_individual_services.date';
}

public static function aggregateByColumn(): string
{
return 'interventions.id';
}

public static function columns(): array
{
return [
Expand Down
5 changes: 5 additions & 0 deletions app/Reports/Queries/Pregnant/P12.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public static function dateColumn(): string
return 'interventionable_individual_services.date';
}

public static function aggregateByColumn(): string
{
return 'interventions.id';
}

public static function columns(): array
{
return [
Expand Down
12 changes: 12 additions & 0 deletions app/Reports/Queries/ReportQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public static function dateColumn(): string
return 'beneficiaries.created_at';
}

public static function aggregateByColumn(): string
{
return 'id';
}

public static function columns(): array
{
return [
Expand Down Expand Up @@ -83,4 +88,11 @@ public static function build(Report $report): Builder
->whereDate(static::dateColumn(), '>=', $report->date_from)
->whereDate(static::dateColumn(), '<=', $report->date_until);
}

public static function aggregate(Report $report): int
{
return static::build($report)
->distinct(static::aggregateByColumn())
->count(static::aggregateByColumn());
}
}

0 comments on commit fa527ad

Please sign in to comment.