<commit_before>var Button = require('./ui/button.js.jsx')
var LoveStore = require('../stores/love_store')
var LoveActionCreators = require('../actions/love_action_creators')
var Icon = require('./ui/icon.js.jsx')
var IconToggler = require('./ui/icon_toggler.js.jsx')
var IconWithNumber = require('./ui/icon_with_number.js.jsx')
var SvgIcon = require('./ui/svg_icon.js.jsx');
const Tile = require('./ui/tile.js.jsx')
const Nav = require('./ui/nav.js.jsx')

var Leaderboard = React.createClass({

  getInitialState: function() {
    return {
      rank_data: [],
      show_all: false
    }
  },

  componentDidMount: function() {
    $.ajax({
      url: '/leaderboards',
      method: 'GET',
      success: function(data) {
          this.setState({rank_data: data});

      }.bind(this)
    });

  },

  renderCategories: function(rank_data) {
    click = function(event) {
      event.stopPropagation()
      event.preventDefault()
      this.setState({show_all: !this.state.show_all})
    }.bind(this)

    var a = _.pairs(rank_data)

    if (this.state.show_all) {
      var showAllLink = <Nav.Item label="Hide" onClick={click} small={true} />
      var category_rankings = a.map(function(c){
          var name = c[0]
          var rankd = c[1]
          return this.renderCategory(name, rankd);
      }.bind(this))
      return (<commit_msg>fixed fatal leaderboard component error<commit_after>var Button = require('./ui/button.js.jsx')
var LoveStore = require('../stores/love_store')
var LoveActionCreators = require('../actions/love_action_creators')
var Icon = require('./ui/icon.js.jsx')
var IconToggler = require('./ui/icon_toggler.js.jsx')
var IconWithNumber = require('./ui/icon_with_number.js.jsx')
var SvgIcon = require('./ui/svg_icon.js.jsx');
const Tile = require('./ui/tile.js.jsx')
const Nav = require('./ui/nav.js.jsx')

var Leaderboard = React.createClass({

  getInitialState: function() {
    return {
      rank_data: [],
      show_all: false
    }
  },

  componentDidMount: function() {
    $.ajax({
      url: '/leaderboards',
      method: 'GET',
      success: function(data) {
          this.setState({rank_data: data});

      }.bind(this)
    });

  },

  renderCategories: function(rank_data) {
    var click = function(event) {
      event.stopPropagation()
      event.preventDefault()
      this.setState({show_all: !this.state.show_all})
    }.bind(this)

    var a = _.pairs(rank_data)

    if (this.state.show_all) {
      var showAllLink = <Nav.Item label="Hide" onClick={click} small={true} />
      var category_rankings = a.map(function(c){
          var name = c[0]
          var rankd = c[1]
          return this.renderCategory(name, rankd);
      }.bind(this))
      return (
{'fraction_non_alphanumeric': 0.1609110947832476, 'fraction_numerical': 0.0014695077149155032, 'mean_word_length': 2.957848837209302, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4934494', 'n_tokens_mistral': 913, 'n_tokens_neox': 895, 'n_words': 169}