<commit_before>import React, { Component } from 'react';
import request from 'browser-request';
import ReactGA from 'react-ga';
import { Grid, Col, Row, Form, Panel, Glyphicon, FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
import MovieListings from './movie-listings';
import Header from './header';
import Footer from './footer';
import styling from '../styles/movie-app.css';

class MovieApp extends Component {

  /*
  Grab the showtimes for a movie, find the unique dates,
  and then return those dates sorted by date.
  */
  static getUniqueDates(movieData) {
    const dates = {};
    movieData.forEach((movie) => {
      Object.keys(movie.showTimes).forEach((movieDate) => {
        dates[movieDate] = true;
      });
    });

    return Object.keys(dates).sort((date1, date2) => {
      const dateNum1 = parseInt(date1.match(/\d+/)[0], 10);
      const dateNum2 = parseInt(date2.match(/\d+/)[0], 10);
      return (dateNum1 > dateNum2) ? 1 : -1;
    });
  }

  constructor() {
    super();
    this.state = {
      movieData: null,
      targetDate: 'loading...',
      availableDates: [],
    };

    request('http://192.168.127.12:3003/maya-mall', (er, response, body) => {
      if (er) {
        throw er;
      }

      const movieData = JSON.parse(body);
      const availableDates = MovieApp.getUniqueDates(movieData);
      // eslint-disable-next-line max-len
      const movieDataSortedByRating = movieData.sort((m1, m2) => ((m1.tomatoMeter > m2.tomatoMeter) ? -1 : 1));
      this.setState({
        movieData: movieDataSortedByRating,
        availableDates,
        targetDate: availableDates[0],
      });
    });

    // track app views with Google Analytics
    ReactGA.initialize('UA-63340534-3');
    ReactGA.pageview(window.location.pathname);

    this.handleDateChange = this.handleDateChange.bind(this);
  }

  handleDateChange(event) {
    this.setState({ targetDate: event.target.value });
  }

  render() {
    const movieData = this.state.movieData;
    let content;

    if (!movieData) {
      content = (
        <div className={styling.spinner}>
          <div className={styling['double-bounce1']} />
          <div className={styling['double-bounce2']} />
        </div>
      );
    } else {<commit_msg>fixed sorting bug<commit_after>import React, { Component } from 'react';
import request from 'browser-request';
import ReactGA from 'react-ga';
import { Grid, Col, Row, Form, Panel, Glyphicon, FormGroup, FormControl, ControlLabel } from 'react-bootstrap';
import MovieListings from './movie-listings';
import Header from './header';
import Footer from './footer';
import styling from '../styles/movie-app.css';

class MovieApp extends Component {

  /*
  Grab the showtimes for a movie, find the unique dates,
  and then return those dates sorted by date.
  */
  static getUniqueDates(movieData) {
    const dates = {};
    movieData.forEach((movie) => {
      Object.keys(movie.showTimes).forEach((movieDate) => {
        dates[movieDate] = true;
      });
    });

    return Object.keys(dates).sort((date1, date2) => {
      const dateNum1 = parseInt(date1.match(/\d+/)[0], 10);
      const dateNum2 = parseInt(date2.match(/\d+/)[0], 10);
      return (dateNum1 > dateNum2) ? 1 : -1;
    });
  }

  constructor() {
    super();
    this.state = {
      movieData: null,
      targetDate: 'loading...',
      availableDates: [],
    };

    request('http://192.168.127.12:3003/maya-mall', (er, response, body) => {
      if (er) {
        throw er;
      }

      const movieData = JSON.parse(body);
      const availableDates = MovieApp.getUniqueDates(movieData);
      // eslint-disable-next-line max-len
      movieData.sort((m1, m2) => ((parseInt(m1.tomatoMeter, 10) > parseInt(m2.tomatoMeter, 10)) ? -1 : 1));
      this.setState({
        movieData,
        availableDates,
        targetDate: availableDates[0],
      });
    });

    // track app views with Google Analytics
    ReactGA.initialize('UA-63340534-3');
    ReactGA.pageview(window.location.pathname);

    this.handleDateChange = this.handleDateChange.bind(this);
  }

  handleDateChange(event) {
    this.setState({ targetDate: event.target.value });
  }

  render() {
    const movieData = this.state.movieData;
    let content;

    if (!movieData) {
      content = (
        <div className={styling.spinner}>
          <div className={styling['double-bounce1']} />
          <div className={styling['double-bounce2']} />
        </div>
      );
    } else {
{'fraction_non_alphanumeric': 0.15038932146829811, 'fraction_numerical': 0.022691879866518355, 'mean_word_length': 2.813401187446989, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6334044', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1418, 'n_words': 313}