@Override
    public void run(AdminStatisticsJobRequest jobRequest) throws Exception {
        var year = jobRequest.getYear();
        var month = jobRequest.getMonth();

        LOGGER.info(">> ADMIN REPORT STATS {} {}", year, month);
        var stopwatch = new StopWatch();
        stopwatch.start("repositories.countActiveExtensions");
        var extensions = repositories.countActiveExtensions();
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        stopwatch.start("repositories.downloadsUntil");
        var downloadsTotal = repositories.downloadsTotal();
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        var lastDate = LocalDateTime.of(year, month, 1, 0, 0).minusMonths(1);
        var lastAdminStatistics = repositories.findAdminStatisticsByYearAndMonth(lastDate.getYear(), lastDate.getMonthValue());
        var lastDownloadsTotal = lastAdminStatistics != null ? lastAdminStatistics.getDownloadsTotal() : 0;
        var downloads = downloadsTotal - lastDownloadsTotal;

        stopwatch.start("repositories.countActiveExtensionPublishers");
        var publishers = repositories.countActiveExtensionPublishers();
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        stopwatch.start("repositories.averageNumberOfActiveReviewsPerActiveExtension");
        var averageReviewsPerExtension = repositories.averageNumberOfActiveReviewsPerActiveExtension();
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        stopwatch.start("repositories.countPublishersThatClaimedNamespaceOwnership");
        var namespaceOwners = repositories.countPublishersThatClaimedNamespaceOwnership();
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        stopwatch.start("repositories.countActiveExtensionsGroupedByExtensionReviewRating");
        var extensionsByRating = repositories.countActiveExtensionsGroupedByExtensionReviewRating();
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        stopwatch.start("repositories.countActiveExtensionPublishersGroupedByExtensionsPublished");
        var publishersByExtensionsPublished = repositories.countActiveExtensionPublishersGroupedByExtensionsPublished();
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        var limit = 10;

        stopwatch.start("repositories.topMostActivePublishingUsers");
        var topMostActivePublishingUsers = repositories.topMostActivePublishingUsers(limit);
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        stopwatch.start("repositories.topNamespaceExtensions");
        var topNamespaceExtensions = repositories.topNamespaceExtensions(limit);
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        stopwatch.start("repositories.topNamespaceExtensionVersions");
        var topNamespaceExtensionVersions = repositories.topNamespaceExtensionVersions(limit);
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());

        stopwatch.start("repositories.topMostDownloadedExtensions");
        var topMostDownloadedExtensions = repositories.topMostDownloadedExtensions(limit);
        stopwatch.stop();
        LOGGER.info("{} took {} ms", stopwatch.getLastTaskName(), stopwatch.getLastTaskTimeMillis());
        LOGGER.info("<< ADMIN REPORT STATS {} {}", year, month);

        var statistics = new AdminStatistics();
        statistics.setYear(year);
        statistics.setMonth(month);
        statistics.setExtensions(extensions);
        statistics.setDownloads(downloads);
        statistics.setDownloadsTotal(downloadsTotal);
        statistics.setPublishers(publishers);
        statistics.setAverageReviewsPerExtension(averageReviewsPerExtension);
        statistics.setNamespaceOwners(namespaceOwners);
        statistics.setExtensionsByRating(extensionsByRating);
        statistics.setPublishersByExtensionsPublished(publishersByExtensionsPublished);
        statistics.setTopMostActivePublishingUsers(topMostActivePublishingUsers);
        statistics.setTopNamespaceExtensions(topNamespaceExtensions);
        statistics.setTopNamespaceExtensionVersions(topNamespaceExtensionVersions);
        statistics.setTopMostDownloadedExtensions(topMostDownloadedExtensions);
        service.saveAdminStatistics(statistics);
    }
@Test
    public void testAdminStatisticsJobRequestHandlerWithPreviousStatistics() throws Exception {
        var expectedStatistics = mockAdminStatistics();
        expectedStatistics.setDownloads(678L);

        var prevStatistics = new AdminStatistics();
        prevStatistics.setDownloadsTotal(5000);
        Mockito.when(repositories.findAdminStatisticsByYearAndMonth(2023, 10)).thenReturn(prevStatistics);

        var request = new AdminStatisticsJobRequest(2023, 11);
        handler.run(request);
        Mockito.verify(service).saveAdminStatistics(expectedStatistics);
    }