<commit_before>angular.module('zentodone').factory('Task', function ($q, $filter, hoodie) {
  // Task types
  var INBOX = 1
  var MIT = 2
  var BR = 3
  var ARCHIVE = 4
  var ONE_DAY = 24*60*60*1000
  var ONE_WEEK = 7*24*60*60*1000

  var debug = new window.$debug('zentodone:Task');

  function Task(title, description, data) {
    debug('new Task with title ' + title + ' and desc ' + description)
    if (angular.isObject(title)) {
      this.data = title
      return
    }

    this.data = data && angular.copy(data) || {};

    angular.extend(this.data, {
      id: Math.random().toString(36).substr(2, 9),
      date: Date.now(),
      dueDate: null,
      taskType: INBOX,
      done: false,
      deleted: false,
      title: title,
      description: description
    });
    debug('created new task ' + JSON.stringify(this.data, null, 4));
  }

  Task.INBOX = INBOX
  Task.MIT = MIT
  Task.BR = BR
  Task.ARCHIVE = ARCHIVE
  Task.ONE_DAY = ONE_DAY
  Task.ONE_WEEK = ONE_WEEK
  Task.types = [,'inbox','mit','br','archive']

  Task.isType = function(type) {
    return type === INBOX || type === MIT || type ===  BR || type === ARCHIVE
  }

  Task.prototype.setDone = function() {
    var data = this.data
    var taskType = data.taskType

    switch (this.data.taskType) {
    case MIT:
      if ($filter('unitsOff')(ONE_DAY, data.dueDate) > 0) {
        taskType = ARCHIVE
      }
      break;
    case BR:
      if ($filter('unitsOff')(ONE_WEEK, data.dueDate) > 0) {
        taskType = ARCHIVE
      }
      break;
    }

    return $q.when(hoodie.store.update('task', this.data.id, {
      done: true,
      taskType: taskType
    }))
  }

  Task.prototype.complete = function() {
    var data = this.data


    // FIXME; deal with recurrence
    return $q.when(hoodie.store.update('task', this.data.id, {
      complete: 100,
    }))
  }

  Task.prototype.setDeleted = function() {
    return $q.when(hoodie.store.update('task', this.data.id, {
      deleted: true,<commit_msg>remove unused var; debug<commit_after>angular.module('zentodone').factory('Task', function ($q, $filter, hoodie) {
  // Task types
  var INBOX = 1
  var MIT = 2
  var BR = 3
  var ARCHIVE = 4
  var ONE_DAY = 24*60*60*1000
  var ONE_WEEK = 7*24*60*60*1000

  var debug = new window.$debug('zentodone:Task');

  function Task(title, description, data) {
    debug('new Task with title ' + title + ' and desc ' + description)
    if (angular.isObject(title)) {
      this.data = title
      return
    }

    this.data = data && angular.copy(data) || {};

    angular.extend(this.data, {
      id: Math.random().toString(36).substr(2, 9),
      date: Date.now(),
      dueDate: null,
      taskType: INBOX,
      done: false,
      deleted: false,
      title: title,
      description: description
    });
    debug('created new task ' + JSON.stringify(this.data, null, 4));
  }

  Task.INBOX = INBOX
  Task.MIT = MIT
  Task.BR = BR
  Task.ARCHIVE = ARCHIVE
  Task.ONE_DAY = ONE_DAY
  Task.ONE_WEEK = ONE_WEEK
  Task.types = [,'inbox','mit','br','archive']

  Task.isType = function(type) {
    return type === INBOX || type === MIT || type ===  BR || type === ARCHIVE
  }

  Task.prototype.setDone = function() {
    var data = this.data
    var taskType = data.taskType

    switch (this.data.taskType) {
    case MIT:
      if ($filter('unitsOff')(ONE_DAY, data.dueDate) > 0) {
        taskType = ARCHIVE
      }
      break;
    case BR:
      if ($filter('unitsOff')(ONE_WEEK, data.dueDate) > 0) {
        taskType = ARCHIVE
      }
      break;
    }

    return $q.when(hoodie.store.update('task', this.data.id, {
      done: true,
      taskType: taskType
    }))
  }

  Task.prototype.complete = function() {
    debug('complete task with title ' + this.data.title);

    // FIXME; deal with recurrence
    return $q.when(hoodie.store.update('task', this.data.id, {
      complete: 100,
    }))
  }

  Task.prototype.setDeleted = function() {
    return $q.when(hoodie.store.update('task', this.data.id, {
      deleted: true,
{'fraction_non_alphanumeric': 0.15137956748695003, 'fraction_numerical': 0.017399950285856326, 'mean_word_length': 2.5579133510167993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7292057', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1370, 'n_words': 312}