<commit_before>const _ = require('lodash');

module.exports = function transformSections(sectionName, section, allPages) {
  if (section.paths) {
    return _.flatMap(
      _.groupBy(allPages, 'sectionName'),
      (groupPages, name) => {
        // Partition index pages from regular ones as those don't need transforming
        const { pages, indices } = partitionPages(groupPages);

        // Transform section itself
        if (sectionName === name && section.transform) {
          return section.transform(pages).concat(indices);
        }

        // Use possible subsection transform
        if (section.paths[name] && section.paths[name].transform) {
          return section.paths[name].transform(pages).concat(indices);
        }

        // No transform, return original pages
        return allPages;
      }
    );
  }

  if (section.transform) {
    const { pages, indices } = partitionPages(allPages);<commit_msg>fix: If there's no transform match, return group pages instead of all<commit_after>const _ = require('lodash');

module.exports = function transformSections(sectionName, section, allPages) {
  if (section.paths) {
    return _.flatMap(
      _.groupBy(allPages, 'sectionName'),
      (groupPages, name) => {
        // Partition index pages from regular ones as those don't need transforming
        const { pages, indices } = partitionPages(groupPages);

        // Transform section itself
        if (sectionName === name && section.transform) {
          return section.transform(pages).concat(indices);
        }

        // Use possible subsection transform
        if (section.paths[name] && section.paths[name].transform) {
          return section.paths[name].transform(pages).concat(indices);
        }

        // No transform, return group pages
        return groupPages;
      }
    );
  }

  if (section.transform) {
    const { pages, indices } = partitionPages(allPages);
{'fraction_non_alphanumeric': 0.1140031233732431, 'fraction_numerical': 0.0, 'mean_word_length': 2.7392996108949417, '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': '6535845', 'n_tokens_mistral': 508, 'n_tokens_neox': 488, 'n_words': 132}