<commit_before># This mixin is used to replicate the functionality of using Embers transitions, but still retain the query params in the url. Query params are supported by Ember, but only in later versions.
# The helpers below simply take the query parameters that are passed to the customTransition function and form a query string that matches the Ember generated one.
# customTransitionToRoute has the same method signature as transitionToRoute, so should be easy to switch back to Ember's built in functionality in the future.

ROUTES = {
  'documents': 'documents',
  'taxonConcept': 'taxon_concepts',
  'taxonConcepts': 'taxon_concepts',
  'legal': 'legal'
}

getQueryString = (queryParams) -> 
  queryString = '?'

  queryString += Object.keys(queryParams).map((key) =>
    getQueryStringItem(key, queryParams[key])
  ).filter(isNotUndefinedOrNull).join('&')

getQueryStringItem = (key, param) ->    
  if Array.isArray(param)
    getArrayQueryStringItem(key, param)
  else if isNotUndefinedOrNull(param)
    key + '=' + param

getArrayQueryStringItem = (queryKey, queryArray) ->
  queryKey + '=' + queryArray.map((param) => 
    param
  ).join('%2C')

isNotUndefinedOrNull = (x) ->
  x != undefined && x != null

@CustomTransition = Ember.Mixin.create
  customTransitionToRoute: (emberRoute, arg2, arg3) ->
    @assignArguments(arguments)
    path = @getPath()

    base_url = window.location.origin + '/#/' + path
    queryString = if @queryParams then getQueryString(@queryParams) else ''

    window.location.href = base_url + queryString

  assignArguments: (args) ->
    emberRoute = args[0]
    @pathArray = emberRoute.split('.').map((path) => ROUTES[path])

    if args.length <= 2
      params = args[1]
      @queryParams = if params then params.queryParams else null
    else
      params = args[2]
      @queryParams = if params then params.queryParams else null
      @model = args[1]

  getPath: () ->
    if @model == undefined
      @pathArray[0]
    else 
      @pathArray[0] + '/' + @model.get('id') + '/' + @pathArray[1]
<commit_msg>add another comment<commit_after># This mixin is used to replicate the functionality of using Embers transitions, but still retain the query params in the url. Query params are supported by Ember, but only in later versions.
# The helpers below simply take the query parameters that are passed to the customTransition function and form a query string that matches the Ember generated one.
# customTransitionToRoute has the same method signature as transitionToRoute, so should be easy to switch back to Ember's built in functionality in the future.

# @refresh has been used in queryParamsDidChange in ..._route.js files to make sure that the new model is loaded when the parameters change. This might be able to be removed when updating Ember.

ROUTES = {
  'documents': 'documents',
  'taxonConcept': 'taxon_concepts',
  'taxonConcepts': 'taxon_concepts',
  'legal': 'legal'
}

getQueryString = (queryParams) -> 
  queryString = '?'

  queryString += Object.keys(queryParams).map((key) =>
    getQueryStringItem(key, queryParams[key])
  ).filter(isNotUndefinedOrNull).join('&')

getQueryStringItem = (key, param) ->    
  if Array.isArray(param)
    getArrayQueryStringItem(key, param)
  else if isNotUndefinedOrNull(param)
    key + '=' + param

getArrayQueryStringItem = (queryKey, queryArray) ->
  queryKey + '=' + queryArray.map((param) => 
    param
  ).join('%2C')

isNotUndefinedOrNull = (x) ->
  x != undefined && x != null

@CustomTransition = Ember.Mixin.create
  customTransitionToRoute: (emberRoute, arg2, arg3) ->
    @assignArguments(arguments)
    path = @getPath()

    base_url = window.location.origin + '/#/' + path
    queryString = if @queryParams then getQueryString(@queryParams) else ''

    window.location.href = base_url + queryString

  assignArguments: (args) ->
    emberRoute = args[0]
    @pathArray = emberRoute.split('.').map((path) => ROUTES[path])

    if args.length <= 2
      params = args[1]
      @queryParams = if params then params.queryParams else null
    else
      params = args[2]
      @queryParams = if params then params.queryParams else null
      @model = args[1]

  getPath: () ->
    if @model == undefined
      @pathArray[0]
    else 
      @pathArray[0] + '/' + @model.get('id') + '/' + @pathArray[1]

{'fraction_non_alphanumeric': 0.11527777777777778, 'fraction_numerical': 0.005092592592592593, 'mean_word_length': 3.806451612903226, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '1115037', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1284, 'n_words': 404}