<commit_before>package com.collective.celos.servlet;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.collective.celos.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists;

/**
 * Returns information about the slot states of a single workflow as JSON.
 *
 * GET /workflow-slots
 * ==>
 * {
 *     "workflows" : [
 *     {
 *       "id": "workflow-1",
 *       "info": {
 *           "url": "http://myurl",
 *           "contacts": [
 *               { "name": "<NAME>", "email": "<EMAIL>"},
 *               { "name": "<NAME>", "email": "<EMAIL>"},
 *           ]
 *       },
 *       "slots": [
 *          { "time": "2013-12-07T13:00:00.000Z", "status": "RUNNING", "externalID": "237982137-371832798321-W", retryCount: 5 },
 *          { "time": "2013-12-07T14:00:00.000Z", "status": "READY", "externalID": null, retryCount: 0 },
 *         ...
 *       ]
 *     }, {
 *       "id": "workflow-2",
 *       "info": {
 *           "url": "http://myurl2",
 *           "contacts": [
 *               { "name": "<NAME>", "email": "<EMAIL>"},
 *               { "name": "<NAME>", "email": "<EMAIL>"},
 *           ]
 *       },
 *       "slots": [
 *          { "time": "2013-12-07T13:00:00.000Z", "status": "RUNNING", "externalID": "237982137-371832798322-W", retryCount: 2 },
 *          { "time": "2013-12-07T14:00:00.000Z", "status": "READY", "externalID": null, retryCount: 0 },
 *         ...
 *       ]
 *     }
 *   ]
 * }
 * If the "time" parameter is supplied, information is returned about
 * slot states up to that time.<commit_msg>Update documentation of workflow-slots servlet.<commit_after>package com.collective.celos.servlet;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.collective.celos.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists;

/**
 * Returns information about the slot states of one or more workflows as JSON.
 *
 * If no id parameter is specified, returns slot states of all workflows.
 *
 * If the id parameter is specified, returns only slot states of that workflow.
 *
 * GET /workflow-slots
 * ==>
 * {
 *     "workflows" : [
 *     {
 *       "id": "workflow-1",
 *       "info": {
 *           "url": "http://myurl",
 *           "contacts": [
 *               { "name": "<NAME>", "email": "<EMAIL>"},
 *               { "name": "<NAME>", "email": "<EMAIL>"},
 *           ]
 *       },
 *       "slots": [
 *          { "time": "2013-12-07T13:00:00.000Z", "status": "RUNNING", "externalID": "237982137-371832798321-W", retryCount: 5 },
 *          { "time": "2013-12-07T14:00:00.000Z", "status": "READY", "externalID": null, retryCount: 0 },
 *         ...
 *       ]
 *     }, {
 *       "id": "workflow-2",
 *       "info": {
 *           "url": "http://myurl2",
 *           "contacts": [
 *               { "name": "<NAME>", "email": "<EMAIL>"},
 *               { "name": "<NAME>", "email": "<EMAIL>"},
 *           ]
 *       },
 *       "slots": [
 *          { "time": "2013-12-07T13:00:00.000Z", "status": "RUNNING", "externalID": "237982137-371832798322-W", retryCount: 2 },
 *          { "time": "2013-12-07T14:00:00.000Z", "status": "READY", "externalID": null, retryCount: 0 },
 *         ...
 *       ]
 *     }
 *   ]
 * }
 *
 * If the "time" parameter is supplied, information is returned about
 * slot states up to that time.
{'fraction_non_alphanumeric': 0.1833372558249, 'fraction_numerical': 0.05507178159566957, 'mean_word_length': 2.5744322960470982, 'pattern_counts': {'":': 60, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '5565082', 'n_tokens_mistral': 1563, 'n_tokens_neox': 1381, 'n_words': 279}