<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';

import R from 'ramda';
import { format, getTime } from 'date-fns';

export class Table extends Component {
  render() {
    const repositories = this.props.repositories;
    const cumulatedCountByRepository = this.props.cumulatedCountByRepository;
    return (
      <table>
        <thead>
          <tr>
            <th>Day</th>
            <th>Total</th>
            {repositories.map(repository => (
              <th key={repository}>{repository}</th>
            ))}
          </tr>
        </thead>
        <tbody>
          {this.props.days.map(day => (
            <tr key={day}>
              <td>{format(day, 'MM/DD/YYYY')}</td>
              <td>
                {R.reduce(
                  (acc, repo) =>
                    acc + (cumulatedCountByRepository[repo][getTime(day)] || 0),
                  0,
                  repositories
                )}
              </td>
              {repositories.map(repository => (
                <td key={repository + day}>
                  {cumulatedCountByRepository[repository][getTime(day)] || 0}
                </td>
              ))}
            </tr>
          ))}
        </tbody>
      </table>
    );
  }
}

Table.propTypes = {
  repositories: PropTypes.array.isRequired,
  days: PropTypes.array.isRequired,
  cumulatedCountByRepository: PropTypes.object.isRequired,
};<commit_msg>Reduce duplication<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';

import R from 'ramda';
import { format, getTime } from 'date-fns';

export class Table extends Component {
  render() {
    const repositories = this.props.repositories;
    const cumulatedCountByRepository = this.props.cumulatedCountByRepository;
    return (
      <table>
        <thead>
          <tr>
            <th>Day</th>
            <th>Total</th>
            {repositories.map(repository => (
              <th key={repository}>{repository}</th>
            ))}
          </tr>
        </thead>
        <tbody>
          {this.props.days.map(day => {
            const time = getTime(day);
            return (
              <tr key={day}>
                <td>{format(day, 'MM/DD/YYYY')}</td>
                <td>
                  {R.reduce(
                    (acc, repo) =>
                      acc + (cumulatedCountByRepository[repo][time] || 0),
                    0,
                    repositories
                  )}
                </td>
                {repositories.map(repository => (
                  <td key={repository + day}>
                    {cumulatedCountByRepository[repository][time] || 0}
                  </td>
                ))}
              </tr>
            );
          })}
        </tbody>
      </table>
    );
  }
}

Table.propTypes = {
  repositories: PropTypes.array.isRequired,
  days: PropTypes.array.isRequired,
  cumulatedCountByRepository: PropTypes.object.isRequired,
};
{'fraction_non_alphanumeric': 0.13152610441767068, 'fraction_numerical': 0.002008032128514056, 'mean_word_length': 1.4970760233918128, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 55, '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': '6779701', 'n_tokens_mistral': 864, 'n_tokens_neox': 818, 'n_words': 153}