Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JoaoPedro's avatar

Laravel octane Octane::concurrently

I have this two functions in an laravel api with laravel octane:

public function analyzeRepositoryCommits(string $repository_id, array ...$jsons) { $tasks = []; foreach ($jsons as $json) { $tasks[] = fn() => $this->getTotalCommitsForEachDay($repository_id, $json); }

    $results = Octane::concurrently($tasks);

    $total_commits_per_day = $this->generateLast90Days();
    foreach($results as $result) {
        foreach($result as $date => $total_commits) {
            $total_commits_per_day[$date] += $total_commits;
        }
    }

    ksort($total_commits_per_day);
    $this->cacheResult($repository_id, $total_commits_per_day);

    return $total_commits_per_day;
}

private function getTotalCommitsForEachDay(string $repository_id, array $json)
{
    $totalCommits = [];
    foreach($json as $data) {
        $commit_date = Carbon::parse($data["commit"]["committer"]["date"])
            ->format("ymd");
        $this->commit_service->create(new CommitDTO(
            $data["node_id"],
            $data["author"]["login"],
            $data["author"]["id"],
            $repository_id,
            $commit_date
        ));
        if(array_key_exists($commit_date, $totalCommits)) {
            $totalCommits[$commit_date] += 1;
            continue;
        }
        $totalCommits[$commit_date] = 1;
    }
    return $totalCommits;
}

when my $jsons variable has a second+ indice with only one element in it, i"m getting false as a result on those indices in the $results variable, but if i have the second+ indice with more than one element it gives me the correct result for them, why?

0 likes
0 replies

Please or to participate in this conversation.