<commit_before>// Lemonade stand

var state = {
  buyers: [],
  temperature: 75,
  sunny: 1,
  price: 1.00,
  updatePending: false,

  addBuyer: function() {
    newBuyer = new buyer();
    this.buyers.push(newBuyer);
    this.queueUpdate();
    // gender = [ boy, girl];
  },

  removeBuyer: function() {
    oldBuyer = this.buyers.shift();
    this.queueUpdate();
  },

  setTemperature: function(temp) {
    this.temperature = temp;
    this.queueUpdate();
  },

  setPrice: function(price) {
    this.price = price;
    this.queueUpdate();
  },

  setSunny: function(sunny) {
    this.sunny = sunny;
    this.queueUpdate();
  },

  queueUpdate: function() {
    if (!this.updatePending) {
      this.updatePending = true;
      setTimeout(sellerEvaluate, 2500);
    }
  }
};

function sellerEvaluate() {
  var data = {
    numBuyers: state.buyers.length,
    temperature: state.temperature,
    sunny: state.sunny
  };
  console.log(JSON.stringify(data));
  $.ajax({
    method: "POST",
    url: "/data/seller/evaluate",
    data: JSON.stringify(data),
    contentType: 'application/json',
    success: function(data) {
      state.updatePending = false;
      console.log(data);
    }
  });
}

var buyer = function () {
  return {
    evaluate: function() {
      var data = {
        price: state.price,
        numBuyers: state.buyers.length,
        temperature: state.temperature,
        sunny: state.sunny
      };

      $.post("/data/buyer/evaluate", data, function(data) {
        console.log("show buy / no buy");
      });
    }
  }
};

(function(){
  console.log(state);
  let cloudyIcon = document.querySelector('.cloudy-icon-btn'),
      addBuyerLink = document.querySelector("#add-buyer-link"),
      stand = document.querySelector('#stand'),
      snowMount = document.querySelector('#snow'),
      snowMid = document.querySelector("#snow-backer"),
      sunnyIcon = document.querySelector('.sunny-icon-btn'),
      b = document.getElementsByTagName('body')[0],
      bSunny = document.getElementsByClassName('sunny'),
      sun = document.querySelector('.sun'),
      sunnyOrCloudy = document.querySelector('.sunny-or-cloudy'),
      jsNotActive = document.querySelector('.js-not-active'),<commit_msg>set gender when buyer added<commit_after>// Lemonade stand

var state = {
  buyers: [],
  temperature: 75,
  sunny: 1,
  price: 1.00,
  updatePending: false,

  addBuyer: function() {
    var genders = ['boy', 'girl'];
    newBuyer = new buyer();
    newBuyer.gender = genders[Math.floor(Math.random() * genders.length)];
    this.buyers.push(newBuyer);
    this.queueUpdate();
  },

  removeBuyer: function() {
    oldBuyer = this.buyers.shift();
    this.queueUpdate();
  },

  setTemperature: function(temp) {
    this.temperature = temp;
    this.queueUpdate();
  },

  setPrice: function(price) {
    this.price = price;
    this.queueUpdate();
  },

  setSunny: function(sunny) {
    this.sunny = sunny;
    this.queueUpdate();
  },

  queueUpdate: function() {
    if (!this.updatePending) {
      this.updatePending = true;
      setTimeout(sellerEvaluate, 2500);
    }
  }
};

function sellerEvaluate() {
  var data = {
    numBuyers: state.buyers.length,
    temperature: state.temperature,
    sunny: state.sunny
  };
  console.log(JSON.stringify(data));
  $.ajax({
    method: "POST",
    url: "/data/seller/evaluate",
    data: JSON.stringify(data),
    contentType: 'application/json',
    success: function(data) {
      state.updatePending = false;
      console.log(data);
    }
  });
}

var buyer = function () {
  return {
    gender: 'boy',
    evaluate: function() {
      var data = {
        price: state.price,
        numBuyers: state.buyers.length,
        temperature: state.temperature,
        sunny: state.sunny
      };

      $.post("/data/buyer/evaluate", data, function(data) {
        console.log("show buy / no buy");
      });
    }
  }
};

(function(){
  console.log(state);
  let cloudyIcon = document.querySelector('.cloudy-icon-btn'),
      addBuyerLink = document.querySelector("#add-buyer-link"),
      stand = document.querySelector('#stand'),
      snowMount = document.querySelector('#snow'),
      snowMid = document.querySelector("#snow-backer"),
      sunnyIcon = document.querySelector('.sunny-icon-btn'),
      b = document.getElementsByTagName('body')[0],
      bSunny = document.getElementsByClassName('sunny'),
      sun = document.querySelector('.sun'),
      sunnyOrCloudy = document.querySelector('.sunny-or-cloudy'),
      jsNotActive = document.querySelector('.js-not-active'),
{'fraction_non_alphanumeric': 0.15507786795349857, 'fraction_numerical': 0.00482561965343277, 'mean_word_length': 2.941227312013829, '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': '6115268', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1458, 'n_words': 259}