// $qb->where($qb->expr()->isNotNull('userAgent.additionalHeaders'));
foreach ($qb->getQuery()->getResult() as $key => $userAgent) {
    /* @var $userAgent \UserAgentParserComparison\Entity\UserAgent */
    $qb = $resultRepo->createQueryBuilder('result');
    $qb->join('result.provider', 'provider');
    $qb->join('result.userAgent', 'userAgent');
    $qb->where('result.userAgent = :userAgent');
    $qb->setParameter(':userAgent', $userAgent->id);
    $qb->orderBy('provider.name');
    $results = $qb->getQuery()->getResult();
    if (count($results) === 0) {
        throw new \Exception('no results found...' . $qb->getQuery()->getSQL());
    }
    $generate = new UserAgentDetail($entityManager);
    $generate->setTitle('User agent detail - ' . $userAgent->string);
    $generate->setUserAgent($userAgent);
    $generate->setResults($results);
    /*
     * create the folder
     */
    $folder = $basePath . '/user-agent-detail/' . substr($userAgent->id, 0, 2) . '/' . substr($userAgent->id, 2, 2);
    if (!file_exists($folder)) {
        mkdir($folder, 0777, true);
    }
    /*
     * persist!
     */
    file_put_contents($folder . '/' . $userAgent->id . '.html', $generate->getHtml());
    if ($key % 100 === 0) {
        $entityManager->clear();
    }
    /* @var $uaEvaluation \UserAgentParserComparison\Entity\UserAgentEvaluation */
    $uaEvaluation = $uaEvaluationRepo->findOneBy(['userAgent' => $row['uaId']]);
    $qb = $resultRepo->createQueryBuilder('result');
    $qb->join('result.provider', 'provider');
    $qb->join('result.userAgent', 'userAgent');
    $qb->join('result.resultEvaluation', 'resultEvaluation');
    $qb->where('result.userAgent = :userAgent');
    $qb->setParameter(':userAgent', $row['uaId']);
    $qb->orderBy('provider.name');
    $results = $qb->getQuery()->getResult();
    if (count($results) === 0) {
        throw new \Exception('no results found...' . $qb->getQuery()->getSQL());
    }
    $generate = new UserAgentDetail();
    $generate->setTitle($row['uaString']);
    $generate->setUserAgent($row['uaString']);
    $generate->setUserAgentEvaluation($uaEvaluation);
    $generate->setResults($results);
    /*
     * create the folder
     */
    $folder = $basePath . '/user-agent-detail/' . substr($row['uaId'], 0, 2) . '/' . substr($row['uaId'], 2, 2);
    if (!file_exists($folder)) {
        mkdir($folder, null, true);
    }
    /*
     * persist!
     */
    file_put_contents($folder . '/' . $row['uaId'] . '.html', $generate->getHtml());
    echo '.';
}