Dont sync members that have no joined_at date
This commit is contained in:
parent
eb6dd27bf4
commit
59a82ac015
|
@ -39,6 +39,9 @@ class InitializeMembers {
|
||||||
$this->bar->task('Synchronisiere Mitglieder', function() {
|
$this->bar->task('Synchronisiere Mitglieder', function() {
|
||||||
$this->api->search([])->each(function($member) {
|
$this->api->search([])->each(function($member) {
|
||||||
$member = NamiMember::fromNami($this->api->member($member->group_id, $member->id));
|
$member = NamiMember::fromNami($this->api->member($member->group_id, $member->id));
|
||||||
|
if (!$member->joined_at) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$m = Member::create([
|
$m = Member::create([
|
||||||
'firstname' => $member->firstname,
|
'firstname' => $member->firstname,
|
||||||
|
|
|
@ -110,11 +110,27 @@ class InitializeTest extends TestCase
|
||||||
'location' => '::location::',
|
'location' => '::location::',
|
||||||
'version' => 40,
|
'version' => 40,
|
||||||
]);
|
]);
|
||||||
$this->assertEquals([306], Activity::firstWhere('nami_id', 305)->subactivities()->pluck('nami_id')->toArray());
|
$this->assertEquals([306], Activity::where('nami_id', 305)->firstOrFail()->subactivities()->pluck('nami_id')->toArray());
|
||||||
|
|
||||||
Http::assertSentCount(13);
|
Http::assertSentCount(13);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItDoesntGetMembersWithNoJoinedAtDate(): void
|
||||||
|
{
|
||||||
|
$this->withoutExceptionHandling();
|
||||||
|
$this->initializeProvider(function($backend) {
|
||||||
|
$backend->fakeMembers([$this->member(['eintrittsdatum' => null])]);
|
||||||
|
});
|
||||||
|
$this->post('/login', [
|
||||||
|
'mglnr' => 123,
|
||||||
|
'password' => 'secret',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->post('/initialize');
|
||||||
|
|
||||||
|
$this->assertDatabaseCount('members', 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, array<int, int>>
|
* @return array<int, array<int, int>>
|
||||||
*/
|
*/
|
||||||
|
@ -133,32 +149,14 @@ class InitializeTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @dataProvider pageProvider
|
* @dataProvider pageProvider
|
||||||
*/
|
*/
|
||||||
public function testItInitializesPages($num): void
|
public function testItInitializesPages(int $num): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
$this->initializeProvider(function($backend) use ($num) {
|
$this->initializeProvider(function($backend) use ($num) {
|
||||||
$members = collect([]);
|
$members = collect([]);
|
||||||
|
|
||||||
foreach (range(1, $num) as $i) {
|
foreach (range(1, $num) as $i) {
|
||||||
$members->push([
|
$members->push($this->member(['id' => $i]));
|
||||||
'vorname' => '::firstname::',
|
|
||||||
'nachname' => '::lastname::',
|
|
||||||
'beitragsartId' => 300,
|
|
||||||
'geburtsDatum' => '2014-07-11 00:00:00',
|
|
||||||
'gruppierungId' => 1000,
|
|
||||||
'geschlechtId' => 303,
|
|
||||||
'id' => $i,
|
|
||||||
'eintrittsdatum' => '2020-11-17 00:00:00',
|
|
||||||
'geschlechtId' => 303,
|
|
||||||
'landId' => 302,
|
|
||||||
'staatsangehoerigkeitId' => 291,
|
|
||||||
'zeitschriftenversand' => true,
|
|
||||||
'strasse' => '::street',
|
|
||||||
'plz' => '12345',
|
|
||||||
'ort' => '::location::',
|
|
||||||
'version' => 40,
|
|
||||||
'gruppierung' => '::group::',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$backend->fakeMembers($members->toArray());
|
$backend->fakeMembers($members->toArray());
|
||||||
|
@ -174,4 +172,31 @@ class InitializeTest extends TestCase
|
||||||
$this->assertDatabaseCount('members', $num);
|
$this->assertDatabaseCount('members', $num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $overwrites
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function member(array $overwrites): array
|
||||||
|
{
|
||||||
|
return array_merge([
|
||||||
|
'vorname' => '::firstname::',
|
||||||
|
'nachname' => '::lastname::',
|
||||||
|
'beitragsartId' => 300,
|
||||||
|
'geburtsDatum' => '2014-07-11 00:00:00',
|
||||||
|
'gruppierungId' => 1000,
|
||||||
|
'geschlechtId' => 303,
|
||||||
|
'id' => 116,
|
||||||
|
'eintrittsdatum' => '2020-11-17 00:00:00',
|
||||||
|
'geschlechtId' => 303,
|
||||||
|
'landId' => 302,
|
||||||
|
'staatsangehoerigkeitId' => 291,
|
||||||
|
'zeitschriftenversand' => true,
|
||||||
|
'strasse' => '::street',
|
||||||
|
'plz' => '12345',
|
||||||
|
'ort' => '::location::',
|
||||||
|
'version' => 40,
|
||||||
|
'gruppierung' => '::group::',
|
||||||
|
], $overwrites);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue