<commit_before>package pl.matsuo.gitlab.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import static org.springframework.http.HttpStatus.*;
import static org.springframework.web.bind.annotation.RequestMethod.*;


/**
 * Created by marek on 04.07.15.
 */
@Controller
@RequestMapping("/gl")
public class GitlabProxyController {


  @Value("#{environment.PRIVATE_TOKEN}")
  private String gitlabPrivateToken;
  @Value("#{environment.GITLAB_SERVER}")
  private String gitlabServer;


  @RequestMapping(value = "/projects/{user}/{project}/issues", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectIssues(@PathVariable("user") String user,
                       @PathVariable("project") String project,
                       @RequestParam(value = "labels", required = false) String labels,
                       @RequestParam(value = "status", required = false) String status,
                       @RequestParam(value = "milestone", required = false) String milestone) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/issues?"
        + (labels != null ? "labels=" + labels + "&" : "")
        + (status != null ? "status=" + status + "&" : "")
        + (milestone != null ? "milestone=" + milestone + "&" : ""));
  }



  @RequestMapping(value = "/projects/{user}/{project}/milestones", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectMilestones(@PathVariable("user") String user,
		                       @PathVariable("project") String project) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/milestones");
  }


  @RequestMapping(value = "/projects/{idProject}/issues/{idIssue}/notes", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectNotes(@PathVariable("idProject") Integer idProject,
                      @PathVariable("idIssue") Integer idIssue) {
    return sendGet(gitlabServer + "/api/v3/projects/" + idProject + "/issues/" + idIssue + "/notes");
  }


  @RequestMapping(value = "/projects/{user}/{project}/repository/tree", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String listFiles(@PathVariable("user") String user,
                       @PathVariable("project") String project,
                       @RequestParam(value = "path") String path,
                       @RequestParam(value = "ref_name") String ref_name) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/repository/tree?"
        + (path != null ? "path=" + path + "&" : "")
        + (ref_name != null ? "ref_name=" + ref_name + "&" : ""));
  }


  @RequestMapping(value = "/projects/{user}/{project}/repository/files", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String getFile(@PathVariable("user") String user,
                   @PathVariable("project") String project,
                   @RequestParam(value = "file_path") String file_path,
                   @RequestParam(value = "ref") String ref) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/repository/files?"
        + (file_path != null ? "file_path=" + file_path + "&" : "")
        + (ref != null ? "ref=" + ref + "&" : ""));
  }


  // HTTP GET request
  private String sendGet(String url) {
    try {
      URL obj = new URL(url);
      HttpURLConnection con = (HttpURLConnection) obj.openConnection();

      // optional default is GET
      con.setRequestMethod("GET");

      // set user agent
      con.setRequestProperty("User-Agent", "kosher/1.0");
      con.setRequestProperty("PRIVATE-TOKEN", gitlabPrivateToken);

      // FIXME: response codes from controller based on this response code
      int responseCode = con.getResponseCode();
      System.out.println("Response code: " + responseCode + " for url " + url);

      BufferedReader in = new BufferedReader(
          new InputStreamReader(con.getInputStream()));
      String inputLine;
      StringBuffer response = new StringBuffer();

      while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
      }
      in.close();

      return response.toString();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

<commit_msg>Status should be state<commit_after>package pl.matsuo.gitlab.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import static org.springframework.http.HttpStatus.*;
import static org.springframework.web.bind.annotation.RequestMethod.*;


/**
 * Created by marek on 04.07.15.
 */
@Controller
@RequestMapping("/gl")
public class GitlabProxyController {


  @Value("#{environment.PRIVATE_TOKEN}")
  private String gitlabPrivateToken;
  @Value("#{environment.GITLAB_SERVER}")
  private String gitlabServer;


  @RequestMapping(value = "/projects/{user}/{project}/issues", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectIssues(@PathVariable("user") String user,
                       @PathVariable("project") String project,
                       @RequestParam(value = "labels", required = false) String labels,
                       @RequestParam(value = "state", required = false) String state,
                       @RequestParam(value = "milestone", required = false) String milestone) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/issues?"
        + (labels != null ? "labels=" + labels + "&" : "")
        + (state != null ? "state=" + state + "&" : "")
        + (milestone != null ? "milestone=" + milestone + "&" : ""));
  }



  @RequestMapping(value = "/projects/{user}/{project}/milestones", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectMilestones(@PathVariable("user") String user,
		                       @PathVariable("project") String project) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/milestones");
  }


  @RequestMapping(value = "/projects/{idProject}/issues/{idIssue}/notes", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectNotes(@PathVariable("idProject") Integer idProject,
                      @PathVariable("idIssue") Integer idIssue) {
    return sendGet(gitlabServer + "/api/v3/projects/" + idProject + "/issues/" + idIssue + "/notes");
  }


  @RequestMapping(value = "/projects/{user}/{project}/repository/tree", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String listFiles(@PathVariable("user") String user,
                       @PathVariable("project") String project,
                       @RequestParam(value = "path") String path,
                       @RequestParam(value = "ref_name") String ref_name) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/repository/tree?"
        + (path != null ? "path=" + path + "&" : "")
        + (ref_name != null ? "ref_name=" + ref_name + "&" : ""));
  }


  @RequestMapping(value = "/projects/{user}/{project}/repository/files", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String getFile(@PathVariable("user") String user,
                   @PathVariable("project") String project,
                   @RequestParam(value = "file_path") String file_path,
                   @RequestParam(value = "ref") String ref) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/repository/files?"
        + (file_path != null ? "file_path=" + file_path + "&" : "")
        + (ref != null ? "ref=" + ref + "&" : ""));
  }


  // HTTP GET request
  private String sendGet(String url) {
    try {
      URL obj = new URL(url);
      HttpURLConnection con = (HttpURLConnection) obj.openConnection();

      // optional default is GET
      con.setRequestMethod("GET");

      // set user agent
      con.setRequestProperty("User-Agent", "kosher/1.0");
      con.setRequestProperty("PRIVATE-TOKEN", gitlabPrivateToken);

      // FIXME: response codes from controller based on this response code
      int responseCode = con.getResponseCode();
      System.out.println("Response code: " + responseCode + " for url " + url);

      BufferedReader in = new BufferedReader(
          new InputStreamReader(con.getInputStream()));
      String inputLine;
      StringBuffer response = new StringBuffer();

      while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
      }
      in.close();

      return response.toString();
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}


{'fraction_non_alphanumeric': 0.14360697039680873, 'fraction_numerical': 0.003569179088809574, 'mean_word_length': 3.1748466257668713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6744526', 'n_tokens_mistral': 2716, 'n_tokens_neox': 2624, 'n_words': 579}