Skip to content

Commit 3b53093

Browse files
Rework family insert to use inserts and chunks like person does.
1 parent bc14886 commit 3b53093

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/Utils/FamilyData.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,36 @@ public static function getFamily($conn, $families, $obje_ids, $sour_ids, $person
5050

5151
$chan = $family->getChan();
5252

53-
$husband_id = (isset($persons_id[$husb])) ? $persons_id[$husb] : 0;
54-
$wife_id = (isset($persons_id[$wife])) ? $persons_id[$wife] : 0;
53+
$husband_id = (isset($persons_id[$husb])) ? $persons_id[$husb] : 0;
54+
$wife_id = (isset($persons_id[$wife])) ? $persons_id[$wife] : 0;
5555

56-
Family::on($conn)->updateOrCreate(
57-
compact('husband_id', 'wife_id', 'description', 'type_id', 'nchi', 'rin')
58-
);
56+
// $family = Family::on($conn)->updateOrCreate(
57+
// compact('husband_id', 'wife_id', 'description', 'type_id', 'nchi', 'rin')
58+
// );
5959

6060
// $value = ['husband_id'=>$husband_id, 'wife_id'=>$wife_id, 'description'=>$description, 'type_id'=>$type_id, 'nchi'=>$nchi, 'rin'=>$rin];
6161
// $familydata [] = $value;
6262
}
6363
// Family::insert($familyData);
64+
65+
$key = [
66+
['husband_id', $husband_id], ['wife_id', $wife_id], ['description', $description], ['type_id', $type_id], ['nchi', $nchi],
67+
['rin', $rin]
68+
];
69+
$check = Family::on($conn)->where($key)->first();
70+
if (empty($check)) {
71+
$value = ['husband_id'=>$husband_id, 'wife_id'=>$wife_id];
72+
73+
$FamilyData[] = $value;
74+
}
75+
// $person = Person::on($conn)->updateOrCreate($key,$value);
76+
// otherFields::insertOtherFields($conn,$individual,$obje_ids,$person);
77+
78+
79+
foreach (array_chunk($FamilyData, 200) as $chunk) {
80+
Family::on($conn)->insert($chunk);
81+
}
6482
otherFamRecord::insertFamilyData($conn, $families, $obje_ids, $sour_ids);
6583
}
6684
}
85+

src/Utils/GedcomParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class GedcomParser
3636
protected $repo_ids = [];
3737
protected $conn = '';
3838

39-
public function parse($conn, string $filename, string $slug, bool $progressBar = false)
39+
public function parse($conn, string $filename, string $slug, bool $progressBar = NULL)
4040
{
4141
DB::disableQueryLog();
4242
//start calculating the time

0 commit comments

Comments
 (0)