<commit_before>'use strict';

var React = require('react'),
    BaobabBranchMixin = require('baobab-react/mixins').branch,
    filtersFacet = require('../utils/filtersFacet');


var SIZE = 50;

module.exports = React.createClass({
  displayName: 'climateDebateExplorer/explorer/verbatims',
  mixins: [ BaobabBranchMixin ],
  cursors: {
    filters: ['appState', 'filters'],
    fields: ['cached', 'config', 'fields']
  },



  componentDidMount: function() {
    this.cursors.filters.on('update', this._loadListAsync.bind(this, false));
    this._loadList(false);
  },
  componentWillUnmount: function() {
    // WTF ?!? It comes from some other code of mine, and it cannot work.
    // Though, I'll leave it here, to preserve the "logic" of the thing...
    this.cursors.filters.off('update', this._loadListAsync.bind(this, false));
  },
  handleScroll: function() {
    if (this.state.fullList)
      return;

    var bottom = this.refs.bottom,
        verbatims = this.refs.verbatims;

    if (verbatims.scrollTop + verbatims.offsetHeight > bottom.offsetTop)
      this._loadList(true);
  },
  deploy: function(e) {
    // This feature is disabled at the moment, please come back later...
    return;

    var id = e.currentTarget.getAttribute('data-id');

    if (this.state.deployed !== id)
      this.setState({ deployed: id });
  },
  collapse: function(e) {
    this.setState({ deployed: undefined });
  },



  _loadListAsync: function(morePosts) {
    setTimeout(this._loadList.bind(this, false), 0);
  },
  _loadList: function(morePosts) {
    var k,
        faceted = filtersFacet(
          this.state.filters,
          this.state.fields
        );

    this.context.tree.datastore.query(
      { query: faceted,
        from: morePosts ?
          (this.state.results || []).length :
          0,
        size: SIZE },
      (function(queryResult) {
        var verbatims = morePosts ?
          (this.state.verbatims || []).concat(queryResult.hits) :
          queryResult.hits;<commit_msg>[explore] Verbatims: Fixed list sort order<commit_after>'use strict';

var React = require('react'),
    BaobabBranchMixin = require('baobab-react/mixins').branch,
    filtersFacet = require('../utils/filtersFacet');


var SIZE = 50;

module.exports = React.createClass({
  displayName: 'climateDebateExplorer/explorer/verbatims',
  mixins: [ BaobabBranchMixin ],
  cursors: {
    filters: ['appState', 'filters'],
    fields: ['cached', 'config', 'fields']
  },



  componentDidMount: function() {
    this.cursors.filters.on('update', this._loadListAsync.bind(this, false));
    this._loadList(false);
  },
  componentWillUnmount: function() {
    // WTF ?!? It comes from some other code of mine, and it cannot work.
    // Though, I'll leave it here, to preserve the "logic" of the thing...
    this.cursors.filters.off('update', this._loadListAsync.bind(this, false));
  },
  handleScroll: function() {
    if (this.state.fullList)
      return;

    var bottom = this.refs.bottom,
        verbatims = this.refs.verbatims;

    if (verbatims.scrollTop + verbatims.offsetHeight > bottom.offsetTop)
      this._loadList(true);
  },
  deploy: function(e) {
    // This feature is disabled at the moment, please come back later...
    return;

    var id = e.currentTarget.getAttribute('data-id');

    if (this.state.deployed !== id)
      this.setState({ deployed: id });
  },
  collapse: function(e) {
    this.setState({ deployed: undefined });
  },



  _loadListAsync: function(morePosts) {
    setTimeout(this._loadList.bind(this, false), 0);
  },
  _loadList: function(morePosts) {
    var k,
        faceted = filtersFacet(
          this.state.filters,
          this.state.fields
        );

    this.context.tree.datastore.query(
      { query: faceted,
        sort: ['event_id', 'id'],
        from: morePosts ?
          (this.state.results || []).length :
          0,
        size: SIZE },
      (function(queryResult) {
        var verbatims = morePosts ?
          (this.state.verbatims || []).concat(queryResult.hits) :
          queryResult.hits;
{'fraction_non_alphanumeric': 0.14331288343558282, 'fraction_numerical': 0.00196319018404908, 'mean_word_length': 2.878211227402474, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4140172', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1273, 'n_words': 279}