Fixed: Sync missing subactivity
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
25bee98dac
commit
ebdf764ad0
|
@ -100,9 +100,24 @@ class InitializeMembers {
|
||||||
[$groupAll, $groupName, $groupId] = $groupMatches;
|
[$groupAll, $groupName, $groupId] = $groupMatches;
|
||||||
$group = Group::create(['name' => $groupName, 'nami_id' => $groupId]);
|
$group = Group::create(['name' => $groupName, 'nami_id' => $groupId]);
|
||||||
}
|
}
|
||||||
$subactivityId = $membership['entries_untergliederung'] === ''
|
if ($membership['entries_untergliederung'] === '') {
|
||||||
? null
|
$subactivityId = null;
|
||||||
: Subactivity::where('name', $membership['entries_untergliederung'])->firstOrFail()->id;
|
} else if (!Subactivity::where('name', $membership['entries_untergliederung'])->exists()) {
|
||||||
|
try {
|
||||||
|
$singleMembership = $this->api->membership($member->id, $membership['id']);
|
||||||
|
} catch (RightException $e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
app(ActivityCreator::class)->createFor($this->api, $singleMembership['gruppierungId']);
|
||||||
|
$subactivity = Subactivity::where('nami_id', $singleMembership['untergliederungId'])->firstOrFail();
|
||||||
|
$subactivityId = $subactivity->id;
|
||||||
|
$group = Group::firstOrCreate(['nami_id' => $singleMembership['gruppierungId']], [
|
||||||
|
'nami_id' => $singleMembership['gruppierungId'],
|
||||||
|
'name' => $singleMembership['gruppierung'],
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$subactivityId = Subactivity::where('name', $membership['entries_untergliederung'])->first()->id;
|
||||||
|
}
|
||||||
$activity = Activity::where('nami_id', (int) $activityMatches[1])->first();
|
$activity = Activity::where('nami_id', (int) $activityMatches[1])->first();
|
||||||
if (!$activity) {
|
if (!$activity) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -164,7 +164,47 @@ class InitializeTest extends TestCase
|
||||||
|
|
||||||
public function membershipDataProvider() {
|
public function membershipDataProvider() {
|
||||||
return [
|
return [
|
||||||
'fetch_group_from_backend' => [
|
'fetch_subactivity_from_group' => [
|
||||||
|
[
|
||||||
|
'gruppierung' => '::newgroup:: 22',
|
||||||
|
'id' => 1077,
|
||||||
|
'untergliederung' => '::newuntertaetigkeit::',
|
||||||
|
],
|
||||||
|
function($db) {
|
||||||
|
$db->assertDatabaseHas('subactivities', ['name' => 'wö2', 'nami_id' => 3007]);
|
||||||
|
$db->assertDatabaseHas('activity_subactivity', [
|
||||||
|
'activity_id' => Activity::where('nami_id', 305)->firstOrFail()->id,
|
||||||
|
'subactivity_id' => Subactivity::where('nami_id', 3007)->firstOrFail()->id,
|
||||||
|
]);
|
||||||
|
$db->assertDatabaseHas('memberships', [
|
||||||
|
'activity_id' => Activity::where('nami_id', 305)->firstOrFail()->id,
|
||||||
|
'subactivity_id' => Subactivity::where('nami_id', 3007)->firstOrFail()->id,
|
||||||
|
'group_id' => Group::where('nami_id', 9056)->firstOrFail()->id,
|
||||||
|
'nami_id' => 1077,
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
function($backend) {
|
||||||
|
return $backend->fakeSingleMembership(116, 1077, [
|
||||||
|
'aktivVon' => '2021-08-22 00:00:00',
|
||||||
|
'aktivBis' => '',
|
||||||
|
'gruppierungId' => 9056,
|
||||||
|
'gruppierung' => '::newgroup::',
|
||||||
|
'id' => 1077,
|
||||||
|
'taetigkeitId' => 305, // default
|
||||||
|
'taetigkeit' => 'wö',
|
||||||
|
'untergliederung' => '::newuntertaetigkeit::',
|
||||||
|
'untergliederungId' => 3007,
|
||||||
|
])
|
||||||
|
->fakeActivities(9056, [['name' => '€ leiter', 'id' => 305]])
|
||||||
|
->fakeSubactivities([
|
||||||
|
305 => [
|
||||||
|
['name' => 'wö', 'id' => 306],
|
||||||
|
['name' => 'wö2', 'id' => 3007],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'fetch_activity_from_group' => [
|
||||||
[
|
[
|
||||||
'gruppierung' => '::newgroup:: 22',
|
'gruppierung' => '::newgroup:: 22',
|
||||||
'id' => 1077,
|
'id' => 1077,
|
||||||
|
|
Loading…
Reference in New Issue