<commit_before>// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.restapi.v2;

import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.JsonFormat;
import com.yahoo.slime.Slime;
import com.yahoo.vespa.hosted.provision.maintenance.JobControl;

import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;

/** A response containing maintenance job status */
public class JobsResponse extends HttpResponse {

    private final JobControl jobControl;

    public JobsResponse(JobControl jobControl) {
        super(200);
        this.jobControl = jobControl;
    }

    @Override
    public void render(OutputStream stream) throws IOException {
        Slime slime = new Slime();
        Cursor root = slime.setObject();

        Cursor jobArray = root.setArray("jobs");
        for (String jobName : jobControl.jobs())
            jobArray.addObject().setString("name", jobName);

        Cursor inactiveArray = root.setArray("inactive");
        for (String jobName : jobControl.inactiveJobs())
            inactiveArray.addString(jobName);

        new JsonFormat(true).encode(stream, slime);
    }

    @Override
    public String getContentType() { return "application/json"; }

}
<commit_msg>Sort jobs response<commit_after>// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.restapi.v2;

import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.JsonFormat;
import com.yahoo.slime.Slime;
import com.yahoo.vespa.hosted.provision.maintenance.JobControl;

import java.io.IOException;
import java.io.OutputStream;
import java.util.TreeSet;

/** A response containing maintenance job status */
public class JobsResponse extends HttpResponse {

    private final JobControl jobControl;

    public JobsResponse(JobControl jobControl) {
        super(200);
        this.jobControl = jobControl;
    }

    @Override
    public void render(OutputStream stream) throws IOException {
        Slime slime = new Slime();
        Cursor root = slime.setObject();
        Cursor jobArray = root.setArray("jobs");
        for (String jobName : new TreeSet<>(jobControl.jobs()))
            jobArray.addObject().setString("name", jobName);

        Cursor inactiveArray = root.setArray("inactive");
        for (String jobName : new TreeSet<>(jobControl.inactiveJobs()))
            inactiveArray.addString(jobName);

        new JsonFormat(true).encode(stream, slime);
    }

    @Override
    public String getContentType() { return "application/json"; }

}

{'fraction_non_alphanumeric': 0.10184182015167931, 'fraction_numerical': 0.007222824124232575, 'mean_word_length': 3.511400651465798, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7155348', 'n_tokens_mistral': 819, 'n_tokens_neox': 759, 'n_words': 202}