<commit_before>var AssignmentWorkWeek = function(data) {
  this.work_week = data.work_week;
  this.assignment_id = data.assignment_id();
}

_.extend(AssignmentWorkWeek.prototype, {
  isFutureWorkWeek: function() {
    return moment().isBefore(this.work_week.beginning_of_week());
  },

  onValueChanged: function(newValue) {
    this.work_week.actual_hours(parseInt(this.work_week.actual_hours(), 10) || 0)
    this.work_week.estimated_hours(parseInt(this.work_week.estimated_hours(), 10) || 0)
    
    var workWeekData = _.merge(ko.toJS(this.work_week), {assignment_id: this.assignment_id}),
        url = (workWeekData.id == null ? '/work_weeks.json' : '/work_weeks/' + workWeekData.id + '.json'),
        type = (workWeekData.id == null ? "POST" : "PUT");

    $(document.body).attr('style', 'cursor: wait;');

    // update
    $.ajax({
      url: url,
      type: type,
      data: workWeekData,
      dataType: 'json',
      complete: _.bind(function(response, data, status, jqxhr) {
        $(document.body).removeAttr('style');
      }, this),
      error: _.bind(function(response, data, status, jqxhr) {
        $('.flash-container').append(
          "<p class='flash-error flash'>\
            Unexpected error occurred. Please try again.\
            <a class='close' href='javascript:void(0)'>close</a>\<commit_msg>Missed a few things. Need to set the ID if we're creating a work week in the database. Fix up callback args.<commit_after>var AssignmentWorkWeek = function(data) {
  this.work_week = data.work_week;
  this.assignment_id = data.assignment_id();
}

_.extend(AssignmentWorkWeek.prototype, {
  isFutureWorkWeek: function() {
    return moment().isBefore(this.work_week.beginning_of_week());
  },

  onValueChanged: function(newValue) {
    this.work_week.actual_hours(parseInt(this.work_week.actual_hours(), 10) || 0)
    this.work_week.estimated_hours(parseInt(this.work_week.estimated_hours(), 10) || 0)

    var workWeekData = _.merge(ko.toJS(this.work_week), {assignment_id: this.assignment_id}),
        url = (workWeekData.id == null ? '/work_weeks.json' : '/work_weeks/' + workWeekData.id + '.json'),
        type = (workWeekData.id == null ? "POST" : "PUT");

    $(document.body).attr('style', 'cursor: wait;');

    // update
    $.ajax({
      url: url,
      type: type,
      data: workWeekData,
      dataType: 'json',
      success: _.bind(function(response, status, jqxhr) {
        // set id?
        if(this.work_week.id() == undefined)
          this.work_week.id(response.id);
      }, this),
      complete: _.bind(function() {
        $(document.body).removeAttr('style');
      }, this),
      error: _.bind(function() {
        $('.flash-container').append(
          "<p class='flash-error flash'>\
            Unexpected error occurred. Please try again.\
            <a class='close' href='javascript:void(0)'>close</a>\
{'fraction_non_alphanumeric': 0.16045945005221024, 'fraction_numerical': 0.004872955099199443, 'mean_word_length': 3.2202643171806167, 'pattern_counts': {'":': 0, '<': 9, '<?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': '370575', 'n_tokens_mistral': 949, 'n_tokens_neox': 922, 'n_words': 174}