public Response getRecentJobs()

in api-server/src/main/java/org/apache/cassandra/diff/api/resources/DiffJobsResource.java [77:92]


    public Response getRecentJobs() {

        SortedSet<DBService.JobSummary> recentJobs = Sets.newTreeSet(DBService.JobSummary.COMPARATOR.reversed());
        DateTime now = DateTime.now(DateTimeZone.UTC);
        DateTime maxStartDate = now;
        DateTime minStartDate = maxStartDate.minusDays(30);
        recentJobs.addAll(dbService.fetchJobsStartedBetween(minStartDate, maxStartDate));

        while (recentJobs.size() < 10 && (maxStartDate.compareTo(now.minusDays(90)) >= 0)) {
            maxStartDate = minStartDate;
            minStartDate = minStartDate.minusDays(30);
            recentJobs.addAll(dbService.fetchJobsStartedBetween(minStartDate, maxStartDate));
        }

        return response(recentJobs);
    }