<commit_before>import React from 'react'
import PropTypes from 'prop-types'
import FirebaseApp from '../firebaseapp'

import { getCompLevelStr, getMatchSetStr } from '../helpers'

import CurrentMatchDisplay from './CurrentMatchDisplay'
import LastMatchesTable from './LastMatchesTable'
import UpcomingMatchesTable from './UpcomingMatchesTable'

const compLevelsPlayOrder = {
  qm: 1,
  ef: 2,
  qf: 3,
  sf: 4,
  f: 5,
}

function playOrder(match) {
  return (compLevelsPlayOrder[match.c] * 100000) + (match.m * 100) + match.s
}

class LiveEventPanel extends React.PureComponent {
  state = {
    playedMatches: null,
    unplayedMatches: null,
    matchState: null,
    currentTime: undefined,
  }

  componentDidMount() {
    this.updateCurrentTime()
    setInterval(this.updateCurrentTime, 10000)

    FirebaseApp.database().ref(`/e/${this.props.eventKey}/m`).on('value', (snapshot) => {
      const val = snapshot.val()
      const matches = []
      if (val) {
        Object.keys(val).forEach((shortKey) => {
          const match = val[shortKey]
          match.key = `${this.props.eventKey}_${shortKey}`
          match.shortKey = shortKey
          matches.push(match)
        })
      }
      matches.sort((match1, match2) => playOrder(match1) - playOrder(match2))

      const playedMatches = matches.filter((match) => match.r !== -1 && match.b !== -1)
      const unplayedMatches = matches.filter((match) => match.r === -1 || match.b === -1)
      this.setState({
        playedMatches,
        unplayedMatches,
      })
    })
    FirebaseApp.database().ref(`/le/${this.props.eventKey}`).on('value', (snapshot) => {
      this.setState({
        matchState: snapshot.val(),
      })
    })
  }

  updateCurrentTime = () => {
    this.setState({ currentTime: new Date().getTime() / 1000 })
  }
<commit_msg>Fix next matches in LiveEventPanel<commit_after>import React from 'react'
import PropTypes from 'prop-types'
import FirebaseApp from '../firebaseapp'

import { getCompLevelStr, getMatchSetStr } from '../helpers'

import CurrentMatchDisplay from './CurrentMatchDisplay'
import LastMatchesTable from './LastMatchesTable'
import UpcomingMatchesTable from './UpcomingMatchesTable'

const compLevelsPlayOrder = {
  qm: 1,
  ef: 2,
  qf: 3,
  sf: 4,
  f: 5,
}

function playOrder(match) {
  return (compLevelsPlayOrder[match.c] * 100000) + (match.m * 100) + match.s
}

class LiveEventPanel extends React.PureComponent {
  state = {
    playedMatches: null,
    unplayedMatches: null,
    matchState: null,
    currentTime: undefined,
  }

  componentDidMount() {
    this.updateCurrentTime()
    setInterval(this.updateCurrentTime, 10000)

    FirebaseApp.database().ref(`/e/${this.props.eventKey}/m`).on('value', (snapshot) => {
      const val = snapshot.val()
      const matches = []
      if (val) {
        Object.keys(val).forEach((shortKey) => {
          const match = val[shortKey]
          match.key = `${this.props.eventKey}_${shortKey}`
          match.shortKey = shortKey
          matches.push(match)
        })
      }
      matches.sort((match1, match2) => playOrder(match1) - playOrder(match2))

      const playedMatches = matches.filter((match) => match.r !== -1 && match.b !== -1)
      // Compute next unplayed matches, skipping unplayed matches in the middle of played ones
      let unplayedMatches = [];
      matches.forEach(match => {
        if (match.r !== -1 && match.b !== -1) {
          unplayedMatches = [];
        } else {
          unplayedMatches.push(match);
        }
      });
      this.setState({
        playedMatches,
        unplayedMatches,
      })
    })
    FirebaseApp.database().ref(`/le/${this.props.eventKey}`).on('value', (snapshot) => {
      this.setState({
        matchState: snapshot.val(),
      })
    })
  }

  updateCurrentTime = () => {
    this.setState({ currentTime: new Date().getTime() / 1000 })
  }

{'fraction_non_alphanumeric': 0.14653618336337884, 'fraction_numerical': 0.015967035797064124, 'mean_word_length': 2.864676616915423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '6021024', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1225, 'n_words': 253}