<commit_before>import { h, FunctionalComponent, JSX } from 'preact';
import config from 'consts:config';
import { $datagrid, $row, $column, $dot, $aside, $results } from './styles.css';

interface Props {
  tests?: Tests;
  basePath: string;
}

function gatherSubtestResults(
  test: Test,
  tool: BuildTool,
  tests: Tests,
): Tests {
  if (test.results[tool]) {
    tests[test.meta.title] = test;
  }

  if (test.subTests) {
    Object.entries(test.subTests).map(([testDir, t]) =>
      gatherSubtestResults(t, tool, tests),
    );
  }

  return tests;
}

const DataGrid: FunctionalComponent<Props> = ({
  tests = {},
  basePath,
}: Props) => {
  return (
    <div class={$datagrid}>
      {Object.entries(tests).map(([testDir, test]) => (
        <div class={$row}>
          <div class={$aside}>
            <a href={`${basePath}${testDir}`}>{test.meta && test.meta.title}</a>
          </div>
          <div class={$results}>
            {test.results &&
              Object.entries(test.results).map(([subject, result]) => (
                <span class={$column}>
                  <span data-result={result.meta.result} class={$dot}></span>
                </span>
              ))}
            {test.subTests &&
              config.testSubjects.map(tool => (
                <span class={$column}>
                  {Object.entries(gatherSubtestResults(test, tool, {})).map(
                    ([subject, test]) => (
                      <span
                        data-result={test.results[tool].meta.result}<commit_msg>add tool to datalist, adding titles to subtest dots<commit_after>import { h, FunctionalComponent, JSX } from 'preact';
import config from 'consts:config';
import { $datagrid, $row, $column, $dot, $aside, $results } from './styles.css';

interface Props {
  tests?: Tests;
  basePath: string;
}

function gatherSubtestResults(
  test: Test,
  tool: BuildTool,
  tests: Tests,
): Tests {
  if (test.results[tool]) {
    tests[test.meta.title] = test;
  }

  if (test.subTests) {
    Object.entries(test.subTests).map(([testDir, t]) =>
      gatherSubtestResults(t, tool, tests),
    );
  }

  return tests;
}

const DataGrid: FunctionalComponent<Props> = ({
  tests = {},
  basePath,
}: Props) => {
  return (
    <div class={$datagrid}>
      {Object.entries(tests).map(([testDir, test]) => (
        <div class={$row}>
          <div class={$aside}>
            <a href={`${basePath}${testDir}`}>{test.meta && test.meta.title}</a>
          </div>
          <div class={$results}>
            {test.results &&
              Object.entries(test.results).map(([subject, result]) => (
                <span class={$column}>
                  <span
                    data-tool={subject}
                    title={test.html}
                    data-result={result.meta.result}
                    class={$dot}
                  ></span>
                </span>
              ))}
            {test.subTests &&
              config.testSubjects.map(tool => (
                <span class={$column}>
                  {Object.entries(gatherSubtestResults(test, tool, {})).map(
                    ([subject, test]) => (
                      <span
                        data-tool={tool}
                        data-result={test.results[tool].meta.result}
{'fraction_non_alphanumeric': 0.1639294403892944, 'fraction_numerical': 0.0, 'mean_word_length': 1.9791666666666667, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 41, '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': '5990030', 'n_tokens_mistral': 1015, 'n_tokens_neox': 983, 'n_words': 187}