<commit_before>import React from 'react';
import moment from 'moment';
import pluralize from 'pluralize';

export default class extends React.Component {

  subscriptionHistoryRows() {
    const rows = [];
    this.props.subscriptions.forEach((sub) => {
      const startD = moment(sub.start_date);
      const endD = moment(sub.expiration);
      const calculatedDuration = endD.diff(startD, 'months');
      const duration = calculatedDuration === 0 ? 1 : calculatedDuration
      const matchingTransaction = this.props.premiumCredits.find(transaction => (transaction.source_id === sub.id && transaction.source_type === 'Subscription' && transaction.amount > 0));
      if (matchingTransaction) {
        const amountCredited = matchingTransaction.amount > 6
          ? Math.round(matchingTransaction.amount / 7)
          : 1;
        rows.push(
          <tr key={`${matchingTransaction.id}-credit-subscription-table`} className="subscription-row text-center">
            <td colSpan="5">
              Your school purchased School Premium during your subscription, so we credited your account with {`${amountCredited} ${pluralize('week', amountCredited)}`} of Teacher Premium.
            </td>
          </tr>
        );
      }
      const tds = [
        <td key={`${sub.id}-1-row`}>{moment(sub.created_at).format('MMMM Do, YYYY')}</td>,
        <td key={`${sub.id}-2-row`}>{sub.account_type}</td>,
        <td key={`${sub.id}-3-row`}>{this.paymentContent(sub)}</td>,
        <td key={`${sub.id}-4-row`}>{`${duration} ${pluralize('month', duration)}`}</td>,
        <td key={`${sub.id}-5-row`}>{`${startD.format('MM/DD/YY')} - ${endD.format('MM/DD/YY')}`}</td><commit_msg>use strict math rather than ternary<commit_after>import React from 'react';
import moment from 'moment';
import pluralize from 'pluralize';

export default class extends React.Component {

  subscriptionHistoryRows() {
    const rows = [];
    this.props.subscriptions.forEach((sub) => {
      const startD = moment(sub.start_date);
      const endD = moment(sub.expiration);
      const calculatedDuration = endD.diff(startD, 'months');
      // if duration is calculated as 0, make it 1
      const duration = Math.max(calculatedDuration, 1);
      const matchingTransaction = this.props.premiumCredits.find(transaction => (transaction.source_id === sub.id && transaction.source_type === 'Subscription' && transaction.amount > 0));
      if (matchingTransaction) {
        const amountCredited = matchingTransaction.amount > 6
          ? Math.round(matchingTransaction.amount / 7)
          : 1;
        rows.push(
          <tr key={`${matchingTransaction.id}-credit-subscription-table`} className="subscription-row text-center">
            <td colSpan="5">
              Your school purchased School Premium during your subscription, so we credited your account with {`${amountCredited} ${pluralize('week', amountCredited)}`} of Teacher Premium.
            </td>
          </tr>
        );
      }
      const tds = [
        <td key={`${sub.id}-1-row`}>{moment(sub.created_at).format('MMMM Do, YYYY')}</td>,
        <td key={`${sub.id}-2-row`}>{sub.account_type}</td>,
        <td key={`${sub.id}-3-row`}>{this.paymentContent(sub)}</td>,
        <td key={`${sub.id}-4-row`}>{`${duration} ${pluralize('month', duration)}`}</td>,
        <td key={`${sub.id}-5-row`}>{`${startD.format('MM/DD/YY')} - ${endD.format('MM/DD/YY')}`}</td>
{'fraction_non_alphanumeric': 0.17222222222222222, 'fraction_numerical': 0.007309941520467836, 'mean_word_length': 3.2549751243781095, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 39, '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': '4235306', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1027, 'n_words': 213}