Skip to content

Commit

Permalink
feat: add function to total hectares (#185)
Browse files Browse the repository at this point in the history
* feat: add function to total hectares

* fix: round value
  • Loading branch information
LimberHope authored May 8, 2024
1 parent aeaaa5d commit 10cfd8f
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __invoke(Request $request): TotalSectionHeaderResource
'total_non_profit_count' => $this->getTotalNonProfitCount($projects),
'total_enterprise_count' => $this->getTotalEnterpriseCount($projects),
'total_entries' => $this->getTotalJobsCreatedSum($projects),
'total_hectares_restored' => '-',
'total_hectares_restored' => round($this->getTotalHectaresSum($projects)),
'total_hectares_restored_goal' => $this->getTotalHectaresRestoredGoalSum($projects),
'total_trees_restored' => $this->getTotalTreesRestoredSum($projects),
'total_trees_restored_goal' => $this->getTotalTreesGrownGoalSum($projects),
Expand Down Expand Up @@ -74,4 +74,11 @@ public function getTotalTreesGrownGoalSum($projects)
{
return $projects->sum('trees_grown_goal');
}

public function getTotalHectaresSum($projects)
{
return $projects->sum(function ($project) {
return $project->sitePolygons->sum('calc_area');
});
}
}

0 comments on commit 10cfd8f

Please sign in to comment.