<commit_before># Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/

class Observer::Ticket::CloseTime < ActiveRecord::Observer
  observe 'ticket'

  def after_create(record)
    _check(record)
  end

  def after_update(record)
    _check(record)
  end

  private

  def _check(record)
    #      puts 'check close time'

    # return if we run import mode
    return if Setting.get('import_mode')

    # check if close_time is already set
    return true if record.close_time

    # check if ticket is closed now
    state = Ticket::State.lookup( id: record.state_id )
    state_type = Ticket::StateType.lookup( id: state.state_type_id )
    return true if state_type.name != 'closed'

    # set close_time
    record.close_time = Time.now

    # save ticket
    record.save
  end
end<commit_msg>Moved to before filter.<commit_after># Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/

class Observer::Ticket::CloseTime < ActiveRecord::Observer
  observe 'ticket'

  def before_create(record)
    _check(record)
  end

  def before_update(record)
    _check(record)
  end

  private

  def _check(record)
    #puts 'check close time'

    # return if we run import mode
    return if Setting.get('import_mode')

    # check if close_time is already set
    return true if record.close_time

    # check if ticket is closed now
    state = Ticket::State.lookup( id: record.state_id )
    state_type = Ticket::StateType.lookup( id: state.state_type_id )
    return true if state_type.name != 'closed'

    # set close_time
    record.close_time = Time.now
  end
end
{'fraction_non_alphanumeric': 0.08887507768800497, 'fraction_numerical': 0.009944064636420136, 'mean_word_length': 3.339622641509434, 'pattern_counts': {'":': 0, '<': 5, '<?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': '659427', 'n_tokens_mistral': 536, 'n_tokens_neox': 499, 'n_words': 147}