Skip to content

Commit

Permalink
fixes (#331)
Browse files Browse the repository at this point in the history
* fix: Undefined array key "suffix"

* fix: ambiguous column aggregate

* fix: data truncated for column 'initiator'
  • Loading branch information
andreiio authored Oct 24, 2024
1 parent 6f6eaad commit e8af181
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Exports/Sheets/ReportStatisticSheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function headings(): array
->map(function (array $column) {
$label = $column['label'];

if (filled($column['suffix'])) {
if (filled(data_get($column, 'suffix'))) {
$label .= "\n({$column['suffix']})";
}

Expand Down
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());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('interventionable_cases', function (Blueprint $table) {
$table->string('initiator')->nullable()->change();
});
}
};

0 comments on commit e8af181

Please sign in to comment.