Compare commits
No commits in common. "skip_remember" and "master" have entirely different histories.
skip_remem
...
master
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App\Lib;
|
namespace App\Lib;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Laravel\Scout\Builder;
|
use Laravel\Scout\Builder;
|
||||||
use Spatie\LaravelData\Data;
|
use Spatie\LaravelData\Data;
|
||||||
|
|
||||||
|
|
@ -41,20 +40,4 @@ abstract class ScoutFilter extends Data
|
||||||
{
|
{
|
||||||
return static::factory()->withoutMagicalCreation()->from($post ?: []);
|
return static::factory()->withoutMagicalCreation()->from($post ?: []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection<int, string> $filter
|
|
||||||
* @param array<string, bool|null> $conditions
|
|
||||||
* @return Collection<int, string>
|
|
||||||
*/
|
|
||||||
public function switches(Collection $filter, array $conditions): Collection
|
|
||||||
{
|
|
||||||
foreach ($conditions as $field => $value) {
|
|
||||||
if ($value !== null) {
|
|
||||||
$filter->push($field . ' = ' . ($value ? 'true' : 'false'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $filter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,6 @@ class FilterScope extends ScoutFilter
|
||||||
public ?bool $hasBirthday = null,
|
public ?bool $hasBirthday = null,
|
||||||
public ?bool $hasSvk = null,
|
public ?bool $hasSvk = null,
|
||||||
public ?bool $hasVk = null,
|
public ?bool $hasVk = null,
|
||||||
public ?bool $skipYearlyPrevention = null,
|
|
||||||
public ?bool $skipEventPrevention = null,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -74,7 +72,6 @@ class FilterScope extends ScoutFilter
|
||||||
$this->search = $this->search ?: '';
|
$this->search = $this->search ?: '';
|
||||||
|
|
||||||
return Member::search($this->search, function ($engine, string $query, array $options) {
|
return Member::search($this->search, function ($engine, string $query, array $options) {
|
||||||
/** @var Collection<int, string> */
|
|
||||||
$filter = collect([]);
|
$filter = collect([]);
|
||||||
|
|
||||||
if ($this->hasFullAddress === true) {
|
if ($this->hasFullAddress === true) {
|
||||||
|
|
@ -89,12 +86,12 @@ class FilterScope extends ScoutFilter
|
||||||
if ($this->hasBirthday === true) {
|
if ($this->hasBirthday === true) {
|
||||||
$filter->push('birthday IS NOT NULL');
|
$filter->push('birthday IS NOT NULL');
|
||||||
}
|
}
|
||||||
$filter = $this->switches($filter, [
|
if ($this->hasSvk !== null) {
|
||||||
'skip_yearly_prevention' => $this->skipYearlyPrevention,
|
$filter->push('has_svk = ' . ($this->hasSvk ? 'true' : 'false'));
|
||||||
'skip_event_prevention' => $this->skipEventPrevention,
|
}
|
||||||
'has_vk' => $this->hasVk,
|
if ($this->hasVk !== null) {
|
||||||
'has_svk' => $this->hasSvk,
|
$filter->push('has_vk = ' . ($this->hasVk ? 'true' : 'false'));
|
||||||
]);
|
}
|
||||||
if ($this->ausstand === true) {
|
if ($this->ausstand === true) {
|
||||||
$filter->push('ausstand > 0');
|
$filter->push('ausstand > 0');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,6 @@ class Member extends Model implements Geolocatable, Preventable
|
||||||
'nami_id' => 'integer',
|
'nami_id' => 'integer',
|
||||||
'has_svk' => 'boolean',
|
'has_svk' => 'boolean',
|
||||||
'has_vk' => 'boolean',
|
'has_vk' => 'boolean',
|
||||||
'skip_yearly_prevention' => 'boolean',
|
|
||||||
'skip_event_prevention' => 'boolean',
|
|
||||||
'multiply_pv' => 'boolean',
|
'multiply_pv' => 'boolean',
|
||||||
'multiply_more_pv' => 'boolean',
|
'multiply_more_pv' => 'boolean',
|
||||||
'is_leader' => 'boolean',
|
'is_leader' => 'boolean',
|
||||||
|
|
@ -599,8 +597,6 @@ class Member extends Model implements Geolocatable, Preventable
|
||||||
'group_name' => $this->group->inner_name ?: $this->group->name,
|
'group_name' => $this->group->inner_name ?: $this->group->name,
|
||||||
'has_vk' => $this->has_vk,
|
'has_vk' => $this->has_vk,
|
||||||
'has_svk' => $this->has_svk,
|
'has_svk' => $this->has_svk,
|
||||||
'skip_yearly_prevention' => $this->skip_yearly_prevention,
|
|
||||||
'skip_event_prevention' => $this->skip_event_prevention,
|
|
||||||
'links' => [
|
'links' => [
|
||||||
'show' => route('member.show', ['member' => $this], false),
|
'show' => route('member.show', ['member' => $this], false),
|
||||||
'edit' => route('member.edit', ['member' => $this], false),
|
'edit' => route('member.edit', ['member' => $this], false),
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class YearlyRememberAction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($settings->getYearlyMemberFilter()->getQuery()->get() as $member) {
|
foreach ($settings->yearlyMemberFilter->getQuery()->get() as $member) {
|
||||||
// @todo add this check to FilterScope
|
// @todo add this check to FilterScope
|
||||||
if ($member->getMailRecipient() === null) {
|
if ($member->getMailRecipient() === null) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,4 @@ class PreventionSettings extends LocalSettings
|
||||||
'replyToMail' => $this->replyToMail,
|
'replyToMail' => $this->replyToMail,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getYearlyMemberFilter(): FilterScope
|
|
||||||
{
|
|
||||||
$this->yearlyMemberFilter->skipYearlyPrevention = false;
|
|
||||||
|
|
||||||
return $this->yearlyMemberFilter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,10 +138,10 @@ return [
|
||||||
'key' => env('MEILI_MASTER_KEY', null),
|
'key' => env('MEILI_MASTER_KEY', null),
|
||||||
'index-settings' => [
|
'index-settings' => [
|
||||||
Member::class => [
|
Member::class => [
|
||||||
'filterableAttributes' => ['address', 'birthday', 'ausstand', 'bill_kind', 'group_id', 'memberships', 'has_vk', 'has_svk', 'id', 'skip_yearly_prevention', 'skip_event_prevention'],
|
'filterableAttributes' => ['address', 'birthday', 'ausstand', 'bill_kind', 'group_id', 'memberships', 'has_vk', 'has_svk', 'id'],
|
||||||
'searchableAttributes' => ['fullname', 'address'],
|
'searchableAttributes' => ['fullname', 'address'],
|
||||||
'sortableAttributes' => ['lastname', 'firstname'],
|
'sortableAttributes' => ['lastname', 'firstname'],
|
||||||
'displayedAttributes' => ['age_group_icon', 'group_name', 'links', 'is_leader', 'lastname', 'firstname', 'fullname', 'address', 'ausstand', 'birthday', 'id', 'memberships', 'bill_kind', 'group_id', 'skip_yearly_prevention', 'skip_event_prevention', 'has_vk', 'has_svk'],
|
'displayedAttributes' => ['age_group_icon', 'group_name', 'links', 'is_leader', 'lastname', 'firstname', 'fullname', 'address', 'ausstand', 'birthday', 'id', 'memberships', 'bill_kind', 'group_id'],
|
||||||
'pagination' => [
|
'pagination' => [
|
||||||
'maxTotalHits' => 1000000,
|
'maxTotalHits' => 1000000,
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,6 @@ class MemberFactory extends Factory
|
||||||
'keepdata' => false,
|
'keepdata' => false,
|
||||||
'has_svk' => $this->faker->boolean(),
|
'has_svk' => $this->faker->boolean(),
|
||||||
'has_vk' => $this->faker->boolean(),
|
'has_vk' => $this->faker->boolean(),
|
||||||
'skip_yearly_prevention' => false,
|
|
||||||
'skip_event_prevention' => false,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
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('members', function (Blueprint $table) {
|
|
||||||
$table->boolean('skip_yearly_prevention')->default(false);
|
|
||||||
$table->boolean('skip_event_prevention')->default(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('members', function (Blueprint $table) {
|
|
||||||
$table->dropColumn('skip_yearly_prevention');
|
|
||||||
$table->dropColumn('skip_event_prevention');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -248,18 +248,6 @@ it('notices a few weeks before', function ($date, bool $shouldSend) {
|
||||||
[fn() => now()->subYears(5)->addWeeks(2)->subDay(), false],
|
[fn() => now()->subYears(5)->addWeeks(2)->subDay(), false],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
it('skips members that are marked as skipped for yearly mail', function (bool $skip) {
|
|
||||||
Mail::fake();
|
|
||||||
createMember(['efz' => null, 'skip_yearly_prevention' => $skip]);
|
|
||||||
|
|
||||||
sleep(2);
|
|
||||||
YearlyRememberAction::run();
|
|
||||||
|
|
||||||
$skip
|
|
||||||
? Mail::assertNotSent(YearlyMail::class)
|
|
||||||
: Mail::assertSent(YearlyMail::class);
|
|
||||||
})->with([true, false]);
|
|
||||||
|
|
||||||
it('sets reply to mail', function () {
|
it('sets reply to mail', function () {
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
app(PreventionSettings::class)->fill(['replyToMail' => 'admin@example.com'])->save();
|
app(PreventionSettings::class)->fill(['replyToMail' => 'admin@example.com'])->save();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue