Add stat for agegroups
This commit is contained in:
parent
f4c57c3fa7
commit
affa31a05d
|
@ -32,8 +32,8 @@ class Jsonfile extends CmsCompoundObject
|
||||||
return json_decode($this->content, true);
|
return json_decode($this->content, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVar(string $var)
|
public function getVar(string $var, $default = null)
|
||||||
{
|
{
|
||||||
return array_get($this->markup(), $var);
|
return array_get($this->markup(), $var, $default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,9 +102,17 @@ class ProcessSubmitJob implements ShouldQueue
|
||||||
|
|
||||||
private function addStat(Spreadsheet $s): Spreadsheet
|
private function addStat(Spreadsheet $s): Spreadsheet
|
||||||
{
|
{
|
||||||
$groupBy = $this->event->loadConfig('groupBy');
|
$payload = collect([]);
|
||||||
$stat = Participant::where('event_id', $this->event->id)->get()->groupBy(fn ($p) => data_get($p->payload, $groupBy))->map(fn ($p) => $p->count())->map(fn ($key, $value) => [$value, $key])->values();
|
foreach ($this->event->loadConfig('stat') as $stat) {
|
||||||
$s->sheet('Statistik', $stat->toArray());
|
$stat = Participant::where('event_id', $this->event->id)
|
||||||
|
->get()
|
||||||
|
->groupBy(fn ($p) => data_get($p->payload, $stat))
|
||||||
|
->mapWithKeys(fn ($participants, $groupKey) => [$groupKey => [$groupKey, $participants->count()]])
|
||||||
|
->values();
|
||||||
|
$payload = $payload->merge($stat);
|
||||||
|
}
|
||||||
|
|
||||||
|
$s->sheet('Statistik', $payload->toArray());
|
||||||
|
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,12 +84,12 @@ class Event extends Model
|
||||||
return static::pluck('name', 'id')->toArray();
|
return static::pluck('name', 'id')->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadConfig($v)
|
public function loadConfig($v, $default = null)
|
||||||
{
|
{
|
||||||
$file = $this->slug.'.json';
|
$file = $this->slug.'.json';
|
||||||
throw_unless(Jsonfile::find($file), Exception::class, 'Datei '.$file.' nicht gefunden.');
|
throw_unless(Jsonfile::find($file), Exception::class, 'Datei '.$file.' nicht gefunden.');
|
||||||
|
|
||||||
return Jsonfile::find($file)->getVar($v);
|
return Jsonfile::find($file)->getVar($v, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transformInputs($input)
|
public function transformInputs($input)
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
# ===================================
|
# ===================================
|
||||||
|
|
||||||
columns:
|
columns:
|
||||||
|
id:
|
||||||
|
label: ID
|
||||||
|
|
||||||
firstname:
|
firstname:
|
||||||
label: Vorname
|
label: Vorname
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue