<commit_before>import $ from 'jquery';

export default class ProjectModel {
  static getProjects(doneCallback, failCallback) {
    const token = sessionStorage.getItem('token');

    if (!token) {
      failCallback(401);
      return;
    }

    const path = `/api/projects?access_token=${token}`;

    $.get(path)
    .done(function(result) {
      doneCallback(result);
    })
    .fail(function(e) {
      failCallback(e.status);
    });
  }

  static getProjectInfo(id, doneCallback, failCallback) {
    const token = sessionStorage.getItem('token');

    if (!token) {
      failCallback(401);
      return;
    }

    const path = `/api/projects/${id}?access_token=${token}`;

    $.get(path)
    .done(function(result) {
      doneCallback(result);
    })
    .fail(function(e) {
      failCallback(e.status);
    });
  }

  static getStationsOfProject(id, doneCallback, failCallback) {
    const token = sessionStorage.getItem('token');

    if (!token) {
      failCallback(401);
      return;
    }

    const path = `/api/projects/${id}/stations?access_token=${token}`;

    $.get(path)
    .done(function(result) {
      doneCallback(result);
    })
    .fail(function(e) {
      failCallback(e.status);
    });
  }

  static createProject(body, doneCallback, failCallback) {
    const token = sessionStorage.getItem('token');

    if (!token) {
      failCallback(401);
      return;
    }

    const path = `/api/projects?access_token=${token}`;

    $.post(path, body)
    .done(function(result) {
      doneCallback(result);
    })
    .fail(function(e) {
      failCallback(e.status);
    });
  }
}<commit_msg>use fetch instead of jquery in ProjectModel.js<commit_after>import {fetchJSON, postJSON} from '../utils';

export default class ProjectModel {
  static getProjects(doneCallback, failCallback) {
    const token = sessionStorage.getItem('token');

    if (!token) {
      failCallback(401);
      return;
    }

    fetchJSON(`/api/projects?access_token=${token}`)
      .then(doneCallback)
      .catch(failCallback);
  }

  static getProjectInfo(id, doneCallback, failCallback) {
    const token = sessionStorage.getItem('token');

    if (!token) {
      failCallback(401);
      return;
    }

    fetchJSON(`/api/projects/${id}?access_token=${token}`)
      .then(doneCallback)
      .catch(failCallback);
  }

  static getStationsOfProject(id, doneCallback, failCallback) {
    const token = sessionStorage.getItem('token');

    if (!token) {
      failCallback(401);
      return;
    }

    fetchJSON(`/api/projects/${id}/stations?access_token=${token}`)
      .then(doneCallback)
      .catch(failCallback);
  }

  static createProject(body, doneCallback, failCallback) {
    const token = sessionStorage.getItem('token');

    if (!token) {
      failCallback(401);
      return;
    }

    postJSON(`/api/projects?access_token=${token}`, body)
      .then(doneCallback)
      .catch(failCallback);
  }
}
{'fraction_non_alphanumeric': 0.14892893573614416, 'fraction_numerical': 0.008160489629377763, 'mean_word_length': 2.9972826086956523, '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': '113526', 'n_tokens_mistral': 941, 'n_tokens_neox': 910, 'n_words': 154}