<commit_before>var React = require('react');
var Router = require('react-router');

var api = require('../api');

import LoadingIndicator from './LoadingIndicator';
var PollingMixin = require('../mixins/polling');
var TaskSummary = require('./TaskSummary');

var AppDetails = React.createClass({
  mixins: [PollingMixin, Router.State],

  contextTypes: {
    setHeading: React.PropTypes.func,
  },

  getInitialState() {
    return {
      appId: this.getParams().app,
      app: null,
      tasks: null,
    };
  },

  componentWillMount() {
    api.request(this.getAppUrl(), {
      success: (data) => {
        this.setState({
          app: data
        });
        this.context.setHeading(data.name);
      }
    });
    api.request(this.getPollingUrl(), {
      success: (data) => {
        this.setState({
          tasks: data
        });
      }
    });
  },

  componentWillUnmount() {
    this.context.setHeading(null);
  },

  getAppUrl() {
    return '/apps/' + this.state.appId + '/';
  },

  getPollingUrl() {
    return '/tasks/?app=' + this.state.appId;
  },

  pollingReceiveData(data) {
    this.setState({
      tasks: data
    });
  },

  taskInProgress(task) {
    return task.status == 'in_progress';
  },

  taskPending(task) {
    return task.status == 'pending';
  },

  render() {
    if (this.state.tasks === null || this.state.app === null) {
      return <LoadingIndicator />;
    }

    var {app, tasks} = this.state;
    var activeTaskNodes = [];
    var pendingTaskNodes = [];
    var previousTaskNodes = [];

    tasks.forEach((task) => {
      var node = <TaskSummary key={task.id} task={task} />;
      if (this.taskInProgress(task)) {
        activeTaskNodes.unshift(node);
      } else if (this.taskPending(task)) {
        pendingTaskNodes.unshift(node);
      } else {
        previousTaskNodes.push(node);
      }
    });

    return (
      <div>
        <div className="section">
          <div className="section-header">
            <h2>{app.name} Deploys</h2>
          </div>
          {tasks.length ?
            <ul className="task-list">
              {activeTaskNodes}
              {pendingTaskNodes}
              {previousTaskNodes}
            </ul>
          :
            <p>There have been no deploys for this app.</p>
          }
        </div>
      </div>
    );
  }
});

export default AppDetails;
<commit_msg>removed Router.State mixin and changed appId to work with new router.<commit_after>var React = require('react');
var Router = require('react-router');

var api = require('../api');

import LoadingIndicator from './LoadingIndicator';
var PollingMixin = require('../mixins/polling');
var TaskSummary = require('./TaskSummary');


var AppDetails = React.createClass({
  mixins: [PollingMixin],

  contextTypes: {
    setHeading: React.PropTypes.func,
  },

  getInitialState() {
    return {
      appId: this.props.params.app,
      app: null,
      tasks: null,
    };
  },

  componentWillMount() {
    api.request(this.getAppUrl(), {
      success: (data) => {
        this.setState({
          app: data
        });
        this.context.setHeading(data.name);
      }
    });
    api.request(this.getPollingUrl(), {
      success: (data) => {
        this.setState({
          tasks: data
        });
      }
    });
  },

  componentWillUnmount() {
    this.context.setHeading(null);
  },

  getAppUrl() {
    return '/apps/' + this.state.appId + '/';
  },

  getPollingUrl() {
    return '/tasks/?app=' + this.state.appId;
  },

  pollingReceiveData(data) {
    this.setState({
      tasks: data
    });
  },

  taskInProgress(task) {
    return task.status == 'in_progress';
  },

  taskPending(task) {
    return task.status == 'pending';
  },

  render() {
    if (this.state.tasks === null || this.state.app === null) {
      return <LoadingIndicator />;
    }

    var {app, tasks} = this.state;
    var activeTaskNodes = [];
    var pendingTaskNodes = [];
    var previousTaskNodes = [];

    tasks.forEach((task) => {
      var node = <TaskSummary key={task.id} task={task} />;
      if (this.taskInProgress(task)) {
        activeTaskNodes.unshift(node);
      } else if (this.taskPending(task)) {
        pendingTaskNodes.unshift(node);
      } else {
        previousTaskNodes.push(node);
      }
    });

    return (
      <div>
        <div className="section">
          <div className="section-header">
            <h2>{app.name} Deploys</h2>
          </div>
          {tasks.length ?
            <ul className="task-list">
              {activeTaskNodes}
              {pendingTaskNodes}
              {previousTaskNodes}
            </ul>
          :
            <p>There have been no deploys for this app.</p>
          }
        </div>
      </div>
    );
  }
});

export default AppDetails;

{'fraction_non_alphanumeric': 0.15601503759398497, 'fraction_numerical': 0.000835421888053467, 'mean_word_length': 2.091672046481601, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, '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': '3930579', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1496, 'n_words': 277}