<commit_before>import React from 'react';
import { injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import composeAsyncContainer from '../../common/AsyncContainer';
import { fetchTopicGeocodedStoryCounts, fetchTopicEnglishStoryCounts } from '../../../actions/topicActions';
import StatBar from '../../common/statbar/StatBar';

const localMessages = {
  storyLinkCount: { id: 'topic.summary.timespanInfo.storyLinkCount', defaultMessage: 'Story Links' },
  mediumCount: { id: 'topic.summary.timespanInfo.mediumCount', defaultMessage: 'Media Sources' },
  mediumLinkCount: { id: 'topic.summary.timespanInfo.mediumLinkCount', defaultMessage: 'Media Links' },
  geocodedCount: { id: 'topic.summary.timespanInfo.geocodedCount', defaultMessage: 'Geocoded Stories' },
  englishCount: { id: 'topic.summary.timespanInfo.englishCount', defaultMessage: 'English Stories' },
  storyCount: { id: 'topic.summary.timespanInfo.storyCount', defaultMessage: 'Total Stories' },
};

const TopicTimespanInfo = (props) => {
  const { timespan, geocodedCounts, englishCounts } = props;
  const { formatNumber } = props.intl;
  if ((timespan === null) || (timespan === undefined)) {
    return null;
  }
  return (
    <StatBar
      columnWidth={2}
      stats={[
        { message: localMessages.mediumCount, data: formatNumber(timespan.medium_count) },
        { message: localMessages.mediumLinkCount, data: formatNumber(timespan.medium_link_count) },
        { message: localMessages.storyLinkCount, data: formatNumber(timespan.story_link_count) },
        { message: localMessages.geocodedCount,
          data: formatNumber(geocodedCounts.count / geocodedCounts.total, { style: 'percent' }) },
        { message: localMessages.englishCount,
          data: formatNumber(englishCounts.count / geocodedCounts.total, { style: 'percent' }) },
        { message: localMessages.storyCount, data: formatNumber(timespan.story_count) },
      ]}
    />
  );
};

TopicTimespanInfo.propTypes = {
  // from parent<commit_msg>smarter ordering on topic timespan summary info<commit_after>import React from 'react';
import { injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import composeAsyncContainer from '../../common/AsyncContainer';
import { fetchTopicGeocodedStoryCounts, fetchTopicEnglishStoryCounts } from '../../../actions/topicActions';
import StatBar from '../../common/statbar/StatBar';

const localMessages = {
  storyLinkCount: { id: 'topic.summary.timespanInfo.storyLinkCount', defaultMessage: 'Story Links' },
  mediumCount: { id: 'topic.summary.timespanInfo.mediumCount', defaultMessage: 'Media Sources' },
  mediumLinkCount: { id: 'topic.summary.timespanInfo.mediumLinkCount', defaultMessage: 'Media Links' },
  geocodedCount: { id: 'topic.summary.timespanInfo.geocodedCount', defaultMessage: 'Geocoded Stories' },
  englishCount: { id: 'topic.summary.timespanInfo.englishCount', defaultMessage: 'English Stories' },
  storyCount: { id: 'topic.summary.timespanInfo.storyCount', defaultMessage: 'Total Stories' },
};

const TopicTimespanInfo = (props) => {
  const { timespan, geocodedCounts, englishCounts } = props;
  const { formatNumber } = props.intl;
  if ((timespan === null) || (timespan === undefined)) {
    return null;
  }
  return (
    <StatBar
      columnWidth={2}
      stats={[
        { message: localMessages.storyCount, data: formatNumber(timespan.story_count) },
        { message: localMessages.mediumCount, data: formatNumber(timespan.medium_count) },
        { message: localMessages.storyLinkCount, data: formatNumber(timespan.story_link_count) },
        { message: localMessages.mediumLinkCount, data: formatNumber(timespan.medium_link_count) },
        { message: localMessages.englishCount,
          data: formatNumber(englishCounts.count / geocodedCounts.total, { style: 'percent' }) },
        { message: localMessages.geocodedCount,
          data: formatNumber(geocodedCounts.count / geocodedCounts.total, { style: 'percent' }) },
      ]}
    />
  );
};

TopicTimespanInfo.propTypes = {
  // from parent
{'fraction_non_alphanumeric': 0.13470993117010815, 'fraction_numerical': 0.0004916420845624386, 'mean_word_length': 4.432576769025367, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4620426', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1194, 'n_words': 241}