<commit_before>import {some, intersection, pick} from 'lodash'
import I18n from '@/i18n'

export default new class RescueUnsavedEditsService
  constructor: ->
    @models = []

  okToLeave: (model) ->
    attrs = ['description', 'title', 'body', 'details', 'name', 'reason']
    models = ((model && [model]) || @models)
    if some(models, (m) -> intersection(attrs, m.modifiedAttributes()).length > 0)
      # console.log 'some modified', @models.map (m) ->
      #   modifiedAttrs = intersection(attrs, m.modifiedAttributes())
      #   o = {}
      #   o['new'] = pick(m, modifiedAttrs)
      #   o['old'] = pick(m.unmodified, modifiedAttrs)
      #   o

      if confirm(I18n.t('common.confirm_discard_changes'))
        (model && model.discardChanges()) || true
      else
        false
    else
      @models = []
      true

  add: (model) ->
    @models.push model

  clear: ->
    @models = []
<commit_msg>catch outcome statement if changed<commit_after>import {some, intersection, pick} from 'lodash'
import I18n from '@/i18n'

export default new class RescueUnsavedEditsService
  constructor: ->
    @models = []

  okToLeave: (model) ->
    attrs = ['description', 'title', 'body', 'details', 'name', 'reason', 'statement']
    models = ((model && [model]) || @models)
    if some(models, (m) -> intersection(attrs, m.modifiedAttributes()).length > 0)
      # console.log 'some modified', @models.map (m) ->
      #   modifiedAttrs = intersection(attrs, m.modifiedAttributes())
      #   o = {}
      #   o['new'] = pick(m, modifiedAttrs)
      #   o['old'] = pick(m.unmodified, modifiedAttrs)
      #   o

      if confirm(I18n.t('common.confirm_discard_changes'))
        (model && model.discardChanges()) || true
      else
        false
    else
      @models = []
      true

  add: (model) ->
    @models.push model

  clear: ->
    @models = []

{'fraction_non_alphanumeric': 0.16255364806866954, 'fraction_numerical': 0.0075107296137339056, 'mean_word_length': 2.806122448979592, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '3954012', 'n_tokens_mistral': 606, 'n_tokens_neox': 583, 'n_words': 141}