<commit_before>import Constants              from "../constants";
import Utils                  from "../utils";
import * as requestActions    from "./request";
import * as flashActions      from "./flash";

export function getSitesSuccess(sites) {
  return({
    type: Constants.ACTIONS.GET_SITES_SUCCESS,
    sites: sites,
    sentAt: Date.now()
  });
}

export function getSitesFailure() {
  return({
    type: Constants.ACTIONS.GET_SITES_FAILURE,
    sentAt: Date.now()
  });
}

export function newSiteSuccess(newSite) {
  return({
    type: Constants.ACTIONS.NEW_SITE_SUCCESS,
    newSite: newSite,
    sentAt: Date.now()
  });
}

export function newSiteFailure() {
  return({
    type: Constants.ACTIONS.NEW_SITE_FAILURE,
    sentAt: Date.now()
  });
}

export function setCurrentSite(siteId) {
  return({
    type: Constants.ACTIONS.SET_CURRENT_SITE,
    siteId: siteId,
    sentAt: Date.now()
  });
}

/* Thunks */

const SiteActions = {

  getSites: function() {
    return function(dispatch) {
      dispatch(requestActions.requestStart("GET_SITES"));

      const requestOpts = Utils.makeRequestOptions("GET");

      fetch(Constants.ROUTES.SITES, requestOpts)
      .then((response) => {
        if (response.status == 200)
          return response.json()
        else
          throw "";
      })
      .then((json) => {
        dispatch(requestActions.requestEnd());
        dispatch(getSitesSuccess(json));
      })
      .catch((message) => {
        dispatch(requestActions.requestEnd());
        dispatch(flashActions.flashError("Problem fetching sites: " + message));
        dispatch(getSitesFailure());
      });
    };
  },

  addSite: function(domain, protocol) {
    return function(dispatch) {<commit_msg>linter<commit_after>import Constants              from "../constants";
import Utils                  from "../utils";
import * as requestActions    from "./request";
import * as flashActions      from "./flash";

export function getSitesSuccess(sites) {
  return({
    type: Constants.ACTIONS.GET_SITES_SUCCESS,
    sites: sites,
    sentAt: Date.now()
  });
}

export function getSitesFailure() {
  return({
    type: Constants.ACTIONS.GET_SITES_FAILURE,
    sentAt: Date.now()
  });
}

export function newSiteSuccess(newSite) {
  return({
    type: Constants.ACTIONS.NEW_SITE_SUCCESS,
    newSite: newSite,
    sentAt: Date.now()
  });
}

export function newSiteFailure() {
  return({
    type: Constants.ACTIONS.NEW_SITE_FAILURE,
    sentAt: Date.now()
  });
}

export function setCurrentSite(siteId) {
  return({
    type: Constants.ACTIONS.SET_CURRENT_SITE,
    siteId: siteId,
    sentAt: Date.now()
  });
}

/* Thunks */
const SiteActions = {

  getSites: function() {
    return function(dispatch) {
      dispatch(requestActions.requestStart("GET_SITES"));

      const requestOpts = Utils.makeRequestOptions("GET");

      fetch(Constants.ROUTES.SITES, requestOpts)
      .then((response) => {
        if (response.status == 200)
          return response.json()
        else
          throw "";
      })
      .then((json) => {
        dispatch(requestActions.requestEnd());
        dispatch(getSitesSuccess(json));
      })
      .catch((message) => {
        dispatch(requestActions.requestEnd());
        dispatch(flashActions.flashError("Problem fetching sites: " + message));
        dispatch(getSitesFailure());
      });
    };
  },

  addSite: function(domain, protocol) {
    return function(dispatch) {
{'fraction_non_alphanumeric': 0.1354950781702374, 'fraction_numerical': 0.0017371163867979154, 'mean_word_length': 2.8560267857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2622542', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1058, 'n_words': 200}