Skip to content

Commit

Permalink
[TM-1402] Trim the headers on tree species assocations.
Browse files Browse the repository at this point in the history
  • Loading branch information
roguenet committed Dec 13, 2024
1 parent 888f1d6 commit c8fe1f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/Console/Commands/ImportTreeSpeciesAssociations.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function handle()
protected function parseHeaders(array $headerRow): void
{
foreach ($headerRow as $index => $header) {
$header = trim($header, "\xEF\xBB\xBF\"");
if ($header == 'tree_species_uuid') {
$this->treeSpeciesUuidColumn = $index;
} elseif ($header == 'taxon_id') {
Expand All @@ -95,7 +96,7 @@ protected function parseHeaders(array $headerRow): void
}

$this->assert(
$this->treeSpeciesUuidColumn != null && $this->taxonIdColumn != null,
is_numeric($this->treeSpeciesUuidColumn) && is_numeric($this->taxonIdColumn),
'Not all required columns were found'
);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Commands/OneOff/PopulateTreeSpeciesResearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function handle()
$existing = TreeSpeciesResearch::where('scientific_name', $data['scientific_name'])->first();
$this->assert(
$existing == null,
"Scientific name already exists, skipping: " . json_encode([
'Scientific name already exists, skipping: ' . json_encode([
'existing_id' => $existing?->taxon_id,
'new_id' => $data['taxon_id'],
'scientific_name' => $data['scientific_name'],
Expand All @@ -85,7 +85,7 @@ public function handle()

$progressBar->finish();

if (!empty($abortExceptions)) {
if (! empty($abortExceptions)) {
$this->warn("Errors and warnings encountered during parsing CSV Rows:\n");
foreach ($abortExceptions as $error) {
$this->logException($error);
Expand Down

0 comments on commit c8fe1f9

Please sign in to comment.