<commit_before>Species.DocumentResultComponent = Ember.Component.extend
  layoutName: 'species/components/document-result'
  tagName: 'tr'
  attributeBindings: ['documentId:data-document-id'],

  setup: ( ->
    primaryDocumentId = parseInt(@get('doc.primary_document_id'))
    primaryDocumentVersion = @get('doc.document_language_versions').findBy('id', primaryDocumentId)
    # when things went wrong with translations
    unless primaryDocumentVersion
      primaryDocumentVersion = @get('doc.document_language_versions.firstObject')
    primaryLanguage = primaryDocumentVersion['language']
    allLanguages = @get('doc.document_language_versions').mapBy('language').sort()

    @setProperties(
      language: primaryLanguage,
      languages: allLanguages,
      moreThanOneLanguage: allLanguages.length > 1
    )
  ).on("init")

  documentVersion: ( ->
    @get('doc.document_language_versions').findBy('language', @get('language'))
  ).property('language')

  documentId: ( ->
    @get('documentVersion.id')
  ).property('documentVersion.id')

  documentUrl: ( ->
    "/api/v1/documents/" + @get('documentId')
  ).property('documentId')

  title: ( ->
    @get('documentVersion.title')
  ).property('documentVersion.title')

  isLongTitle: ( ->
    @get('fullTitle').length > 60
  ).property('fullTitle')

  fullTitle: ( ->
    if @get('doc.event_type') == 'CitesCop'
      'Prop ' + (@get('doc.proposal_number') || '') + ': ' + @get('title')
    else
      @get('title')
  ).property('doc.event_type', 'doc.proposal_number', 'title')

  actions:
    startDownload: () ->
      document_id = @get('doc.id')
      url = "/api/v1/documents/#{document_id}"
      $.ajax({
        type: 'GET'
        dataType: 'json'
        url: url
      }).done((data) =>
        doc = data.document_download
        ga('send', {
          hitType: 'event',
          eventCategory: "Downloads: #{doc.event_type}",
          eventAction: doc.event_name,
          label: doc.document_type,
          value: doc.id
        })
      )
      window.location = url
<commit_msg>simplified tracking individual document downloads<commit_after>Species.DocumentResultComponent = Ember.Component.extend
  layoutName: 'species/components/document-result'
  tagName: 'tr'
  attributeBindings: ['documentId:data-document-id'],

  setup: ( ->
    primaryDocumentId = parseInt(@get('doc.primary_document_id'))
    primaryDocumentVersion = @get('doc.document_language_versions').findBy('id', primaryDocumentId)
    # when things went wrong with translations
    unless primaryDocumentVersion
      primaryDocumentVersion = @get('doc.document_language_versions.firstObject')
    primaryLanguage = primaryDocumentVersion['language']
    allLanguages = @get('doc.document_language_versions').mapBy('language').sort()

    @setProperties(
      language: primaryLanguage,
      languages: allLanguages,
      moreThanOneLanguage: allLanguages.length > 1
    )
  ).on("init")

  documentVersion: ( ->
    @get('doc.document_language_versions').findBy('language', @get('language'))
  ).property('language')

  documentId: ( ->
    @get('documentVersion.id')
  ).property('documentVersion.id')

  documentUrl: ( ->
    "/api/v1/documents/" + @get('documentId')
  ).property('documentId')

  title: ( ->
    @get('documentVersion.title')
  ).property('documentVersion.title')

  isLongTitle: ( ->
    @get('fullTitle').length > 60
  ).property('fullTitle')

  fullTitle: ( ->
    if @get('doc.event_type') == 'CitesCop'
      'Prop ' + (@get('doc.proposal_number') || '') + ': ' + @get('title')
    else
      @get('title')
  ).property('doc.event_type', 'doc.proposal_number', 'title')

  actions:
    startDownload: () ->
      url = "/api/v1/documents/#{@get('documentId')}"
      ga('send', {
        hitType: 'event',
        eventCategory: "Downloads: #{@get('doc.event_type')}",
        eventAction: @get('doc.event_name') + ': ' + @get('doc.document_type'),
        label: 'Context: TODO',
        value: @get('documentId')
      })
      window.location = url

{'fraction_non_alphanumeric': 0.16381660470879802, 'fraction_numerical': 0.0024783147459727386, 'mean_word_length': 3.5863636363636364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5632149', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1204, 'n_words': 188}