private function buildRevenueData(array $result, $detailed = false)
    {
        $data = [];

        foreach ($result as $r) {
            $data[$r['date']] = $detailed ? json_decode($r['details'], true) : $r['revenue'];
        }

        return $data;
    }