<commit_before>/* Standalone app that uploads a json schedule */

/* Config */
if(!process.argv[2]) throw 'Please, provide secret as a parameter';

const secret = process.argv[2];
const host = 'mirea.feed4rz.ru';

/* Dependencies */
const schedule = require('../data/schedule.json');
const request = require('request');

function scheduleRemove(term, institute, callback){
  let json = {
    secret : secret,
		term : term,
		institute : institute
  };

  request({ method : 'POST', url : `http://${host}/api/schedule/remove/all`, json : json }, (e, r, b) => {
    if(e){
      callback(e, null);
    } else if(r.statusCode != 200){
      callback(r.statusCode, null);
    } else {
      let result = b;

      if(result.success){
        let response = result.response;

        callback(null, result.response);
      } else {
        callback(result.err, null);
      }
    }
  });
}

function scheduleNew(schedule, callback){
  let json = {
    secret : secret,
    schedule : schedule
  };

  request({ method : 'POST', url : `http://${host}/api/schedule/new`, json : json }, (e, r, b) => {
    if(e){
      callback(e, null);
    } else if(r.statusCode != 200){
      callback(r.statusCode, null);
    } else {
      let result = b;

      if(result.success){
        let response = result.response;

        callback(null, result.response);
      } else {
        callback(result.err, null);
      }
    }
  });
}

function groupRemove(term, institute, callback){
  let json = {
    secret : secret,
		term : term,
		institute : institute
  };

  request({ method : 'POST', url : `http://${host}/api/group/remove/all`, json : json }, (e, r, b) => {
    if(e){
      callback(e, null);
    } else if(r.statusCode != 200){
      callback(r.statusCode, null);
    } else {
      let result = b;

      if(result.success){
        let response = result.response;

        callback(null, result.response);
      } else {
        callback(result.err, null);
      }
    }
  });
}

function groupNew(group, callback){
  let json = {
    secret : secret,
    group : group
  };

  request({ method : 'POST', url : `http://${host}/api/group/new`, json : json }, (e, r, b) => {
    if(e){
      callback(e, null);
    } else if(r.statusCode != 200){
      callback(r.statusCode, null);
    } else {
      let result = b;

      if(result.success){
        let response = result.response;

        callback(null, result.response);
      } else {
        callback(result.err, null);
      }
    }
  });
}

scheduleRemove(schedule[0].term, schedule[0].institute, (err, res) => {
  if(err){
    throw err;
  } else {
		console.log('Current schedule: clear');

    groupRemove(schedule[0].term, schedule[0].institute, (err, res) => {
      if(err){
        throw err;
      } else {
				console.log('Current group list: clear');
				
        for(let i = 0; i < schedule.length; i++){
          scheduleNew(schedule[i], (err, res) => {});

          let group = {
            institute : schedule[i].institute,
            group : schedule[i].group,
            secret : schedule[i].secret
          };

          groupNew(group, (err, res) => {});
        }
<commit_msg>Removed incorrect parameters<commit_after>/* Standalone app that uploads a json schedule */

/* Config */
if(!process.argv[2]) throw 'Please, provide secret as a parameter';

const secret = process.argv[2];
const host = 'mirea.feed4rz.ru';

/* Dependencies */
const schedule = require('../data/schedule.json');
const request = require('request');

function scheduleRemove(term, institute, callback){
  let json = {
    secret : secret,
		term : term,
		institute : institute
  };

  request({ method : 'POST', url : `http://${host}/api/schedule/remove/all`, json : json }, (e, r, b) => {
    if(e){
      callback(e, null);
    } else if(r.statusCode != 200){
      callback(r.statusCode, null);
    } else {
      let result = b;

      if(result.success){
        let response = result.response;

        callback(null, result.response);
      } else {
        callback(result.err, null);
      }
    }
  });
}

function scheduleNew(schedule, callback){
  let json = {
    secret : secret,
    schedule : schedule
  };

  request({ method : 'POST', url : `http://${host}/api/schedule/new`, json : json }, (e, r, b) => {
    if(e){
      callback(e, null);
    } else if(r.statusCode != 200){
      callback(r.statusCode, null);
    } else {
      let result = b;

      if(result.success){
        let response = result.response;

        callback(null, result.response);
      } else {
        callback(result.err, null);
      }
    }
  });
}

function groupRemove(institute, callback){
  let json = {
    secret : secret,
		institute : institute
  };

  request({ method : 'POST', url : `http://${host}/api/group/remove/all`, json : json }, (e, r, b) => {
    if(e){
      callback(e, null);
    } else if(r.statusCode != 200){
      callback(r.statusCode, null);
    } else {
      let result = b;

      if(result.success){
        let response = result.response;

        callback(null, result.response);
      } else {
        callback(result.err, null);
      }
    }
  });
}

function groupNew(group, callback){
  let json = {
    secret : secret,
    group : group
  };

  request({ method : 'POST', url : `http://${host}/api/group/new`, json : json }, (e, r, b) => {
    if(e){
      callback(e, null);
    } else if(r.statusCode != 200){
      callback(r.statusCode, null);
    } else {
      let result = b;

      if(result.success){
        let response = result.response;

        callback(null, result.response);
      } else {
        callback(result.err, null);
      }
    }
  });
}

scheduleRemove(schedule[0].term, schedule[0].institute, (err, res) => {
  if(err){
    throw err;
  } else {
		console.log('Current schedule: clear');

    groupRemove(schedule[0].institute, (err, res) => {
      if(err){
        throw err;
      } else {
				console.log('Current group list: clear');

        for(let i = 0; i < schedule.length; i++){
          scheduleNew(schedule[i], (err, res) => {});

          let group = {
            institute : schedule[i].institute,
            group : schedule[i].group,
            secret : schedule[i].secret
          };

          groupNew(group, (err, res) => {});
        }

{'fraction_non_alphanumeric': 0.16476008897362568, 'fraction_numerical': 0.006196377502383222, 'mean_word_length': 2.2940868655154367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '6856552', 'n_tokens_mistral': 2061, 'n_tokens_neox': 1975, 'n_words': 476}