<commit_before># Frontend Search Implementation - ViewModel for Search#show
# Handles almost all logic for the view.
# Is not based on the Search model, but the resultSet that the Presenter queries
# from the remote index.
# Patterns: Model-Template-Presenter structure
class Clarat.Search.Cell.SearchResults
  constructor: (@resultSet, @model) ->
    viewObjectFocus = if @model.isPersonal()
                        @personalFocusViewObject
                      else
                        @remoteFocusViewObject

    return _.merge viewObjectFocus(), @generalViewObject()

  generalViewObject: =>

    @addValuesToSearchResults()
    main_offers: @mainResults.hits
    main_count: @mainResults.nbHits
    main_results_query: @mainResultsQuery()
    more_informaiton_text: @moreInformationText()
    more_info_text: I18n.t('js.search.more_info_text')
    more_info_button: I18n.t('js.search.more_info_button')
    pagination: new Clarat.Search.Cell.Pagination(@mainResults)
    offers_path: location.pathname
    toggle_search_result_details: 'Expand/Collapse'
    algolia_logo_path: image_path('banner--powered-by-algolia.svg')
    headline_sort_order: I18n.t('js.search.headlines.sort')
    sort_order: @model.getSortOrders()
    personal: @model.isPersonal()

    personal_anchor: I18n.t(
      'js.search_results.personal_anchor', count: @resultSet.results[0].nbHits
    )
    remote_anchor: I18n.t(
      'js.search_results.remote_anchor', count: @resultSet.results[1].nbHits
    )
    switch_href: window.location.href # TODO: offers_path(search_form: search_cache.remote_focus)
    personalActiveClass:
      if @model.contact_type is 'personal' then 'Type-results__item--active' else ''
    remoteActiveClass:
      if @model.contact_type is 'remote' then 'Type-results__item--active' else ''

  personalFocusViewObject: =>
    @mainResults = @resultSet.results[0]
    @remoteResults = @resultSet.results[1]

    return specificViewObject =
      personal_focus_with_remote:
        @mainResults.nbHits + @remoteResults.nbHits > 0
      main_results_headline: @mainResultsHeadline('personal_offers')
      main_results_location: @mainResultsLocation()
      remote_results_headline:
        I18n.t 'js.search_results.remote_offers', count: @remoteResults.nbHits

      faq_text: I18n.t('js.search_results.faq_text')
      faq_anchor: I18n.t('js.search_results.faq_anchor')
      faq_href: "#{I18n.t('js.routes.faq')}#questions_about_our_search"

      has_two_or_more_remote_results: @remoteResults.nbHits > 1
      remote_offers: @remoteResults.hits

  remoteFocusViewObject: =>
    @mainResults = @resultSet.results[1]

    return specificViewObject =
      personal_focus_with_remote: false
      main_results_headline: @mainResultsHeadline('remote_offers')
      remote_focus: true
      toggle_personal_anchor: I18n.t('js.search_results.show_personal') # TODO: permanent? +css


  mainResultsHeadline: (i18nKey) ->
    if @model.category
      "#{@breadcrumbPath @model}"

  mainResultsQuery: () ->
    if @model.query
      HandlebarsTemplates['remove_query_link'](query: @model.query)

  moreInformationText: () ->
    if @model.category
      "#{@model.category}"
    else if @model.attrs.query
      "#{@model.attrs.query}"

  mainResultsLocation: () ->
    # output = "#{@model.search_location || I18n.t('conf.default_location')}"
    output = @model.search_location
    if @model.exact_location == 'true'
      output += HandlebarsTemplates['remove_exact_location']()

    output<commit_msg>deactivate fake door if user comes from landing-page<commit_after># Frontend Search Implementation - ViewModel for Search#show
# Handles almost all logic for the view.
# Is not based on the Search model, but the resultSet that the Presenter queries
# from the remote index.
# Patterns: Model-Template-Presenter structure
class Clarat.Search.Cell.SearchResults
  constructor: (@resultSet, @model) ->
    viewObjectFocus = if @model.isPersonal()
                        @personalFocusViewObject
                      else
                        @remoteFocusViewObject

    return _.merge viewObjectFocus(), @generalViewObject()

  generalViewObject: =>
    @addValuesToSearchResults()
    main_offers: @mainResults.hits
    main_count: @mainResults.nbHits
    main_results_query: @mainResultsQuery()
    more_informaiton_text: @moreInformationText()
    more_info_text: I18n.t('js.search.more_info_text')
    more_info_button: I18n.t('js.search.more_info_button')
    pagination: new Clarat.Search.Cell.Pagination(@mainResults)
    offers_path: location.pathname
    toggle_search_result_details: 'Expand/Collapse'
    algolia_logo_path: image_path('banner--powered-by-algolia.svg')
    headline_sort_order: I18n.t('js.search.headlines.sort')
    sort_order: @model.getSortOrders()
    personal: @model.isPersonal()

    personal_anchor: I18n.t(
      'js.search_results.personal_anchor', count: @resultSet.results[0].nbHits
    )
    remote_anchor: I18n.t(
      'js.search_results.remote_anchor', count: @resultSet.results[1].nbHits
    )
    switch_href: window.location.href # TODO: offers_path(search_form: search_cache.remote_focus)
    personalActiveClass:
      if @model.contact_type is 'personal' then 'Type-results__item--active' else ''
    remoteActiveClass:
      if @model.contact_type is 'remote' then 'Type-results__item--active' else ''

  personalFocusViewObject: =>
    @mainResults = @resultSet.results[0]
    @remoteResults = @resultSet.results[1]

    return specificViewObject =
      personal_focus_with_remote:
        @mainResults.nbHits + @remoteResults.nbHits > 0
      main_results_headline: @mainResultsHeadline('personal_offers')
      main_results_location: @mainResultsLocation()
      remote_results_headline:
        I18n.t 'js.search_results.remote_offers', count: @remoteResults.nbHits

      faq_text: I18n.t('js.search_results.faq_text')
      faq_anchor: I18n.t('js.search_results.faq_anchor')
      faq_href: "#{I18n.t('js.routes.faq')}#questions_about_our_search"

      has_two_or_more_remote_results: @remoteResults.nbHits > 1
      remote_offers: @remoteResults.hits

  remoteFocusViewObject: =>
    @mainResults = @resultSet.results[1]

    return specificViewObject =
      personal_focus_with_remote: false
      main_results_headline: @mainResultsHeadline('remote_offers')
      remote_focus: true
      toggle_personal_anchor: I18n.t('js.search_results.show_personal') # TODO: permanent? +css


  mainResultsHeadline: (i18nKey) ->
    if @model.category
      "#{@breadcrumbPath @model}"

  mainResultsQuery: () ->
    if @model.query
      HandlebarsTemplates['remove_query_link'](query: @model.query)

  moreInformationText: () ->
    if @model.category
      "#{@model.category}"
    else if @model.attrs.query
      "#{@model.attrs.query}" unless document.referrer.indexOf('/themen/') > -1


  mainResultsLocation: () ->
    # output = "#{@model.search_location || I18n.t('conf.default_location')}"
    output = @model.search_location
    if @model.exact_location == 'true'
      output += HandlebarsTemplates['remove_exact_location']()

    output
{'fraction_non_alphanumeric': 0.11004919184820801, 'fraction_numerical': 0.008854532677442024, 'mean_word_length': 3.914364640883978, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '824703', 'n_tokens_mistral': 2294, 'n_tokens_neox': 2228, 'n_words': 385}