<commit_before>angular.module("admin.orders").controller "ordersCtrl", ($scope, $timeout, RequestMonitor, Orders, SortOptions, $window, $filter) ->
  $scope.RequestMonitor = RequestMonitor
  $scope.pagination = Orders.pagination
  $scope.orders = Orders.all
  $scope.sortOptions = SortOptions
  $scope.per_page_options = [
    {id: 15, name: t('js.admin.orders.index.per_page', results: 15)},
    {id: 50, name: t('js.admin.orders.index.per_page', results: 50)},
    {id: 100, name: t('js.admin.orders.index.per_page', results: 100)}
  ]
  $scope.selected_orders = []
  $scope.checkboxes = {}
  $scope.selected = false
  $scope.select_all = false
  $scope.poll = 0
  $scope.rowStatus = {}

  $scope.initialise = ->
    $scope.per_page = 15
    $scope.q = {
      completed_at_not_null: true
    }
    $scope.fetchResults()

  $scope.fetchResults = (page=1) ->
    $scope.resetSelected()
    params = {
      'q[completed_at_lt]': $scope['q']['completed_at_lt'],
      'q[completed_at_gt]': $scope['q']['completed_at_gt'],
      'q[state_eq]': $scope['q']['state_eq'],
      'q[number_cont]': $scope['q']['number_cont'],
      'q[email_cont]': $scope['q']['email_cont'],
      'q[bill_address_firstname_start]': $scope['q']['bill_address_firstname_start'],
      'q[bill_address_lastname_start]': $scope['q']['bill_address_lastname_start'],
      # Set default checkbox values to null. See: https://github.com/openfoodfoundation/openfoodnetwork/pull/3076#issuecomment-440010498
      'q[completed_at_not_null]': $scope['q']['completed_at_not_null'] || null,
      'q[distributor_id_in]': $scope['q']['distributor_id_in'],
      'q[order_cycle_id_in]': $scope['q']['order_cycle_id_in'],
      'q[s]': $scope.sorting || 'completed_at desc',
      per_page: $scope.per_page,
      page: page
    }
    RequestMonitor.load(Orders.index(params).$promise)

  $scope.resetSelected = ->
    $scope.selected_orders.length = 0
    $scope.selected = false
    $scope.select_all = false
    $scope.checkboxes = {}

  $scope.toggleSelection = (id) ->
    index = $scope.selected_orders.indexOf(id)

    if index == -1
      $scope.selected_orders.push(id)
    else
      $scope.selected_orders.splice(index, 1)
<commit_msg>5299: Add trailing square brackets for array parameters (distributor and order_cycle)<commit_after>angular.module("admin.orders").controller "ordersCtrl", ($scope, $timeout, RequestMonitor, Orders, SortOptions, $window, $filter) ->
  $scope.RequestMonitor = RequestMonitor
  $scope.pagination = Orders.pagination
  $scope.orders = Orders.all
  $scope.sortOptions = SortOptions
  $scope.per_page_options = [
    {id: 15, name: t('js.admin.orders.index.per_page', results: 15)},
    {id: 50, name: t('js.admin.orders.index.per_page', results: 50)},
    {id: 100, name: t('js.admin.orders.index.per_page', results: 100)}
  ]
  $scope.selected_orders = []
  $scope.checkboxes = {}
  $scope.selected = false
  $scope.select_all = false
  $scope.poll = 0
  $scope.rowStatus = {}

  $scope.initialise = ->
    $scope.per_page = 15
    $scope.q = {
      completed_at_not_null: true
    }
    $scope.fetchResults()

  $scope.fetchResults = (page=1) ->
    $scope.resetSelected()
    params = {
      'q[completed_at_lt]': $scope['q']['completed_at_lt'],
      'q[completed_at_gt]': $scope['q']['completed_at_gt'],
      'q[state_eq]': $scope['q']['state_eq'],
      'q[number_cont]': $scope['q']['number_cont'],
      'q[email_cont]': $scope['q']['email_cont'],
      'q[bill_address_firstname_start]': $scope['q']['bill_address_firstname_start'],
      'q[bill_address_lastname_start]': $scope['q']['bill_address_lastname_start'],
      # Set default checkbox values to null. See: https://github.com/openfoodfoundation/openfoodnetwork/pull/3076#issuecomment-440010498
      'q[completed_at_not_null]': $scope['q']['completed_at_not_null'] || null,
      'q[distributor_id_in][]': $scope['q']['distributor_id_in'],
      'q[order_cycle_id_in][]': $scope['q']['order_cycle_id_in'],
      'q[s]': $scope.sorting || 'completed_at desc',
      per_page: $scope.per_page,
      page: page
    }
    RequestMonitor.load(Orders.index(params).$promise)

  $scope.resetSelected = ->
    $scope.selected_orders.length = 0
    $scope.selected = false
    $scope.select_all = false
    $scope.checkboxes = {}

  $scope.toggleSelection = (id) ->
    index = $scope.selected_orders.indexOf(id)

    if index == -1
      $scope.selected_orders.push(id)
    else
      $scope.selected_orders.splice(index, 1)

{'fraction_non_alphanumeric': 0.17378727191811305, 'fraction_numerical': 0.01602136181575434, 'mean_word_length': 4.125427594070696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '4825992', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1546, 'n_words': 236}