<commit_before>package edu.harvard.hms.catalyst.wacct.web;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sun.jersey.spi.resource.Singleton;
import edu.harvard.hms.catalyst.wacct.service.WacctService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;

/**
 * @author <NAME>
 */
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
@Singleton
@Component
public class WacctResource {
    private final Gson gson;
    private WacctService service;

    @Autowired
    public WacctResource(WacctService service) {
        this.service = service;

        final GsonBuilder builder = new GsonBuilder();
        gson = builder.create();
    }

    @POST
    @Path("/capture")
    public Response captureExecutionData() throws IOException {
        service.captureExecutionData();
        return Response.ok().build();
    }

    @POST
    @Path("/reset")
    public Response resetExecutionData() throws IOException {
        service.resetExecutionData();
        return Response.ok().build();
    }

    @GET
    @Path("/list")
    public String listReports() {
        return gson.toJson(service.listReports());
    }

    //TODO
    //delete report?
    //what's the best way to return report?  just redirect?
    //can we collect aggregate data over time? is that useful?
}
<commit_msg>Only apply application/json response type where necessary<commit_after>package edu.harvard.hms.catalyst.wacct.web;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sun.jersey.spi.resource.Singleton;
import edu.harvard.hms.catalyst.wacct.service.WacctService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;

/**
 * @author <NAME>
 */
@Path("/")
@Singleton
@Component
public class WacctResource {
    private final Gson gson;
    private WacctService service;

    @Autowired
    public WacctResource(WacctService service) {
        this.service = service;

        final GsonBuilder builder = new GsonBuilder();
        gson = builder.create();
    }

    @POST
    @Path("/capture")
    public Response captureExecutionData() throws IOException {
        service.captureExecutionData();
        return Response.ok().build();
    }

    @POST
    @Path("/reset")
    public Response resetExecutionData() throws IOException {
        service.resetExecutionData();
        return Response.ok().build();
    }

    @POST
    @Path("/list")
    @Produces(MediaType.APPLICATION_JSON)
    public String listReports() {
        return gson.toJson(service.listReports());
    }

    //TODO
    //delete report?
    //what's the best way to return report?  just redirect?
    //can we collect aggregate data over time? is that useful?
}

{'fraction_non_alphanumeric': 0.11744440964610084, 'fraction_numerical': 0.0, 'mean_word_length': 3.3753424657534246, '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': '3437994', 'n_tokens_mistral': 984, 'n_tokens_neox': 975, 'n_words': 218}