<commit_before>#!/usr/bin/ruby -w
module Rtt
  class Task
    include DataMapper::Resource

    DEFAULT_NAME = 'Default task'

    property :id, Serial
    property :name, Text, :required => true, :default => DEFAULT_NAME
    property :date, Date
    property :start_at, DateTime
    property :end_at, DateTime
    property :active, Boolean, :default => false
    property :accumulated_spent_time, Float, :default => 0

    belongs_to :project
    has 1, :client, :through => :project
    belongs_to :user

    before :valid?, :set_default_project
    before :valid?, :set_default_user

    def self.task(task_name)
      base_attributes = { :name => task_name, :user => Rtt.current_user, :date => Date.today }
      if task_name.nil?
        existing_task = Task.first :active => true
        if existing_task
          existing_task
        else
          base_attributes.merge!(:name => DEFAULT_NAME) if task_name.blank?
          Task.create(base_attributes)
        end
      elsif (existing_task = Task.first base_attributes.merge({:start_at.gte => Date.today.beginning_of_day})).present?
        puts existing_task.accumulated_spent_time
        existing_task
      else
        Task.create(base_attributes)
      end
    end

    def start<commit_msg>Removing logging for Task model<commit_after>#!/usr/bin/ruby -w
module Rtt
  class Task
    include DataMapper::Resource

    DEFAULT_NAME = 'Default task'

    property :id, Serial
    property :name, Text, :required => true, :default => DEFAULT_NAME
    property :date, Date
    property :start_at, DateTime
    property :end_at, DateTime
    property :active, Boolean, :default => false
    property :accumulated_spent_time, Float, :default => 0

    belongs_to :project
    has 1, :client, :through => :project
    belongs_to :user

    before :valid?, :set_default_project
    before :valid?, :set_default_user

    def self.task(task_name)
      base_attributes = { :name => task_name, :user => Rtt.current_user, :date => Date.today }
      if task_name.nil?
        existing_task = Task.first :active => true
        if existing_task
          existing_task
        else
          base_attributes.merge!(:name => DEFAULT_NAME) if task_name.blank?
          Task.create(base_attributes)
        end
      elsif (existing_task = Task.first base_attributes.merge({:start_at.gte => Date.today.beginning_of_day})).present?
        existing_task
      else
        Task.create(base_attributes)
      end
    end

    def start
{'fraction_non_alphanumeric': 0.09613837489943684, 'fraction_numerical': 0.0016090104585679806, 'mean_word_length': 2.8981191222570533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '1596750', 'n_tokens_mistral': 757, 'n_tokens_neox': 734, 'n_words': 189}