<commit_before>class window.TourInterestingUsersView extends Backbone.Marionette.Layout
  template: 'tour/interesting_users_layout'
  className: 'tour-interesting-users'

  events:
    'click .js-left':  'showPreviousPage'
    'click .js-right': 'showNextPage'

  regions:
    tourUsersRegion: '.js-region-tour-users'

  ui:
    left:   '.js-left'
    right:  '.js-right'
    skip:   '.js-skip'
    finish: '.js-finish'

  userListItemWidth: 200 + 2*20 # width of .tour-interesting-user including margin
  numberOfUsersInX: 4
  numberOfUsersInY: 2

  templateHelpers: ->
    next_tourstep_path: window.next_tourstep_path

  initialize: ->
    @page = 0

  onRender: ->
    @ui.finish.hide()
    @tourUsersRegion.show @listView()

    @bindTo @collection, 'add remove reset', @renderListAndPagination
    @renderListAndPagination()

  renderListAndPagination: ->
    @resizeListView()
    @updateButtonStates()

  listView: ->
    @_listView ?= new TourUsersListView
      collection: @collection

  showFinishButton: ->
    @ui.skip.fadeOut =>
      @ui.finish.fadeIn()

  resizeListView: ->
    width = @userListItemWidth * @totalNumberOfItemsInX()
    @listView().$el.width width

  showPage: (page) ->
    @page = page
    xOffset = @userListItemWidth * @numberOfUsersInX * @page
    @listView().$el.css 'left', -xOffset
    @updateButtonStates()

  showPreviousPage: ->
    return unless @hasPreviousPage()
    @showPage @page-1

  showNextPage: ->
    return unless @hasNextPage()
    @showPage @page+1

  hasPreviousPage: ->
    @page > 0

  hasNextPage: -><commit_msg>Shuffle users when rendering<commit_after>class window.TourInterestingUsersView extends Backbone.Marionette.Layout
  template: 'tour/interesting_users_layout'
  className: 'tour-interesting-users'

  events:
    'click .js-left':  'showPreviousPage'
    'click .js-right': 'showNextPage'

  regions:
    tourUsersRegion: '.js-region-tour-users'

  ui:
    left:   '.js-left'
    right:  '.js-right'
    skip:   '.js-skip'
    finish: '.js-finish'

  userListItemWidth: 200 + 2*20 # width of .tour-interesting-user including margin
  numberOfUsersInX: 4
  numberOfUsersInY: 2

  templateHelpers: ->
    next_tourstep_path: window.next_tourstep_path

  initialize: ->
    @page = 0
    @shuffledCollection = new TourUsers

  onRender: ->
    @ui.finish.hide()
    @tourUsersRegion.show @listView()

    @bindTo @collection, 'add remove reset', @updateShuffledCollection
    @updateShuffledCollection()

  updateShuffledCollection: ->
    @shuffledCollection.reset @collection.shuffle()
    @resizeListView()
    @updateButtonStates()

  listView: ->
    @_listView ?= new TourUsersListView
      collection: @shuffledCollection

  showFinishButton: ->
    @ui.skip.fadeOut =>
      @ui.finish.fadeIn()

  resizeListView: ->
    width = @userListItemWidth * @totalNumberOfItemsInX()
    @listView().$el.width width

  showPage: (page) ->
    @page = page
    xOffset = @userListItemWidth * @numberOfUsersInX * @page
    @listView().$el.css 'left', -xOffset
    @updateButtonStates()

  showPreviousPage: ->
    return unless @hasPreviousPage()
    @showPage @page-1

  showNextPage: ->
    return unless @hasNextPage()
    @showPage @page+1

  hasPreviousPage: ->
    @page > 0

  hasNextPage: ->
{'fraction_non_alphanumeric': 0.12362301101591187, 'fraction_numerical': 0.0073439412484700125, 'mean_word_length': 3.3820375335120643, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '5011343', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1052, 'n_words': 212}