Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,25 @@ jobs:
id: psalm
run: |
set +e
vendor/bin/psalm --output-format=json --show-info=false > psalm.json 2>&1
vendor/bin/psalm --output-format=json --show-info=false > psalm.json
EXIT_CODE=$?

# Generate SARIF for GitHub Security
vendor/bin/psalm --output-format=sarif --show-info=false > psalm.sarif 2>&1 || true
vendor/bin/psalm --output-format=sarif --show-info=false > psalm.sarif || true

# Sanitize SARIF: Ensure startLine/Column >= 1 (Psalm sometimes outputs 0)
if [ -f psalm.sarif ]; then
jq '
(.runs[].results[].locations[].physicalLocation.region) |=
(
with_entries(
if .key | endswith("Line") or .key | endswith("Column") then
if .value < 1 then .value = 1 else . end
else . end
)
)
' psalm.sarif > psalm_sanitized.sarif && mv psalm_sanitized.sarif psalm.sarif
fi

ERRORS=$(jq 'length' psalm.json 2>/dev/null || echo "0")
echo "errors=${ERRORS}" >> $GITHUB_OUTPUT
Expand All @@ -200,7 +214,7 @@ jobs:

- name: Upload Psalm SARIF
if: always()
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: psalm.sarif
category: psalm
Expand Down
9 changes: 4 additions & 5 deletions src/Mod/Trees/Console/DonateTreesToTFTF.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ public function handle(): int
$this->info("Created donation batch: {$donation->batch_reference}");

// Mark all confirmed trees as planted
$updated = 0;
foreach ($confirmedTrees as $planting) {
$planting->markPlanted($batchReference);
$updated++;
}
$updated = TreePlanting::markBatchAsPlanted(
$confirmedTrees->modelKeys(),
$batchReference
);

Log::info('Monthly tree donation batch created', [
'batch_reference' => $batchReference,
Expand Down
17 changes: 17 additions & 0 deletions src/Mod/Trees/Models/TreePlanting.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,23 @@ public function markConfirmed(): self
return $this;
}

/**
* Mark a batch of confirmed trees as planted.
*
* @param iterable $ids IDs of the plantings to update
* @param string $batchReference The TFTF batch reference
* @return int Number of updated records
*/
public static function markBatchAsPlanted(iterable $ids, string $batchReference): int
{
return static::whereKey($ids)
->update([
'status' => self::STATUS_PLANTED,
'tftf_reference' => $batchReference,
'updated_at' => now(),
]);
}

/**
* Mark this planting as planted (part of TFTF donation).
*/
Expand Down
Loading