<commit_before>import React, { Component } from 'react';
import { withRouter } from 'react-router';
import { PageHeader } from 'react-bootstrap';
import EUCookie from 'area51-eucookie';

import BoardRow from './BoardRow.js';
import ManagedBy from './ManagedBy.js';
import MessageRow from './MessageRow.js';

//import Stomp from 'stompjs';

/*
* Main class that handles the display of a stations departure board
*/
class Boards extends Component {

  constructor(props) {
    super(props);
    this.state = {
      departures: null
    };
  }

  resetTimer( crs ) {
    const t=this;
    clearTimeout(t.timer);
    t.timer = setTimeout( ()=>t.refresh( crs ), 10000 );
  }

  // Retrieve the latest board
  refresh( crs ) {
    const t = this;
    t.resetTimer( crs )
    fetch( 'http://loge.amsterdam.area51.onl:9888/ldb/boards/' + crs + '?'+new Date())
      .then( res => res.json() )
      .then( departures => t.setState( { departures: departures } ) )
      .catch( e => {
        console.error( e );
      } );
  }

  // Render the departure boards
  renderDepartures( crs, data ) {
    var messages = null, rows = null, idx = 0

    if (data.messages) {
      messages = data.messages
              .filter(msg=>!msg.suppress)
              .map((msg, ind) => {
                  idx++;
                  return  <MessageRow
                              key={'row' + idx}
                              board={this}
                              index={idx}
                              msg={msg}
                          />;
              });
    }

    if (data.departures) {
      rows = data.departures
        // Filter out terminations<commit_msg>Sort departures<commit_after>import React, { Component } from 'react';
import { withRouter } from 'react-router';
import { PageHeader } from 'react-bootstrap';
import EUCookie from 'area51-eucookie';

import BoardRow from './BoardRow.js';
import ManagedBy from './ManagedBy.js';
import MessageRow from './MessageRow.js';

//import Stomp from 'stompjs';
function getTime( loc ) {
  var t=loc.timetable.time,f=loc.forecast.time
  return t?t:f?f:loc.displaytime
}
/*
* Main class that handles the display of a stations departure board
*/
class Boards extends Component {

  constructor(props) {
    super(props);
    this.state = {
      departures: null
    };
  }

  resetTimer( crs ) {
    const t=this;
    clearTimeout(t.timer);
    //t.timer = setTimeout( ()=>t.refresh( crs ), 10000 );
  }

  // Retrieve the latest board
  refresh( crs ) {
    const t = this;
    t.resetTimer( crs )
    fetch( 'https://ldb.a.a51.li/boards/' + crs + '?'+new Date())
      .then( res => res.json() )
      .then( departures => t.setState( { departures: departures } ) )
      .catch( e => {
        console.error( e );
      } );
  }

  // Render the departure boards
  renderDepartures( crs, data ) {
    console.log( data );

    var messages = null, rows = null, idx = 0

    if (data.messages) {
      messages = data.messages
              .filter(msg=>!msg.suppress)
              .map((msg, ind) => {
                  idx++;
                  return  <MessageRow
                              key={'row' + idx}
                              board={this}
                              index={idx}
                              msg={msg}
                          />;
              });
    }

    if (data.departures) {
      rows = data.departures
        .sort( (a,b) => {
          var a1 = getTime(a.location), b1 = getTime(b.location);
          return a1&&b1?(a1 < b1 ? -1 : a1 > b1 ? 1 : 0):0;
        })
        // Filter out terminations
{'fraction_non_alphanumeric': 0.1371841155234657, 'fraction_numerical': 0.009997222993612885, 'mean_word_length': 1.8009331259720063, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 19, 'https://': 1, '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': '7420872', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1100, 'n_words': 278}