Skip to content

Commit

Permalink
#2420 Start of BE changes. Need to think some more about this.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wotuu committed Aug 6, 2024
1 parent 631ce3e commit 37ad7c6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
23 changes: 12 additions & 11 deletions app/Http/Requests/Heatmap/AjaxGetDataFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ public function authorize(): bool
public function rules(): array
{
return [
'dungeon_id' => ['required', Rule::exists(Dungeon::class, 'id')],
'event_type' => ['required', Rule::in(CombatLogEvent::ALL_EVENT_TYPE)],
'data_type' => ['required', Rule::in(CombatLogEvent::ALL_DATA_TYPE)],
'level' => ['nullable', 'regex:/^\d*;\d*$/'],
'affixes' => ['nullable', 'array'],
'affixes.*' => ['integer', Rule::exists(Affix::class, 'id')],
'affix_groups' => ['nullable', 'array'],
'affix_groups.*' => ['integer', Rule::exists(AffixGroup::class, 'id')],
'date_range_from' => ['nullable', 'date_format:Y-m-d'],
'date_range_to' => ['nullable', 'date_format:Y-m-d'],
'duration' => ['nullable', 'regex:/^\d*;\d*$/'],
'dungeon_id' => ['required', Rule::exists(Dungeon::class, 'id')],
'event_type' => ['required', Rule::in(CombatLogEvent::ALL_EVENT_TYPE)],
'data_type' => ['required', Rule::in(CombatLogEvent::ALL_DATA_TYPE)],
'level' => ['nullable', 'regex:/^\d*;\d*$/'],
'affixes' => ['nullable', 'array'],
'affixes.*' => ['integer', Rule::exists(Affix::class, 'id')],
'affix_groups' => ['nullable', 'array'],
'affix_groups.*' => ['integer', Rule::exists(AffixGroup::class, 'id')],
'weekly_affix_groups' => ['integer'],
'date_range_from' => ['nullable', 'date_format:Y-m-d'],
'date_range_to' => ['nullable', 'date_format:Y-m-d'],
'duration' => ['nullable', 'regex:/^\d*;\d*$/'],
];
}
}
Expand Down
22 changes: 21 additions & 1 deletion app/Service/RaiderIO/Dtos/HeatmapDataFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class HeatmapDataFilter implements Arrayable
/** @var Collection<Affix> */
private Collection $affixes;

private ?int $weeklyAffixGroups = null;

private ?Carbon $dateFrom = null;

private ?Carbon $dateTo = null;
Expand Down Expand Up @@ -116,6 +118,18 @@ public function setAffixes(Collection $affixes): HeatmapDataFilter
return $this;
}

public function getWeeklyAffixGroups(): ?int
{
return $this->weeklyAffixGroups;
}

public function setWeeklyAffixGroups(?int $weeklyAffixGroups): HeatmapDataFilter
{
$this->weeklyAffixGroups = $weeklyAffixGroups;

return $this;
}

public function getDateFrom(): ?Carbon
{
return $this->dateFrom;
Expand Down Expand Up @@ -198,7 +212,9 @@ public function toArray(): array
])->toArray();
}

// @TODO Add date ranges (going to get reworked anyway)
if ($this->getWeeklyAffixGroups() !== null) {
$result['weekly_affix_groups'] = $this->getWeeklyAffixGroups();
}

return $result;
}
Expand Down Expand Up @@ -230,6 +246,10 @@ public static function fromArray(array $requestArray): HeatmapDataFilter
$heatmapDataFilter->setAffixGroups(AffixGroup::whereIn('id', $requestArray['affix_groups'])->get());
}

if (isset($requestArray['weekly_affix_groups'])) {
$heatmapDataFilter->setWeeklyAffixGroups($requestArray['weekly_affix_groups']);
}

if (isset($requestArray['date_range_from'])) {
$heatmapDataFilter->setDateFrom(Carbon::createFromFormat('Y-m-d', $requestArray['date_range_from']));
}
Expand Down

0 comments on commit 37ad7c6

Please sign in to comment.