Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Filtering Capabilities to SummaryHtml Formatter #2062

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sweep-ai[bot]
Copy link
Contributor

@sweep-ai sweep-ai bot commented Jan 8, 2025

Purpose

Enhance the SummaryHtml formatter to support advanced filtering of worklog entries during report generation, allowing more granular control over which entries are included in the summary.

This pull request was created to solve the following GitHub issue:

Add a filter to each grouping in the SummaryHtml formatter

Details

No response


Add filtering capability to SummaryHtml formatter groupings

Description:

Extend the SummaryHtmlFormatter to support filtering of worklog entries within each tag grouping, inheriting from the base text formatter while adding HTML-specific filtering functionality.

Tasks:

  1. In app/formatters/SummaryHtml/SummaryHtmlFormatterConfiguration.ts:

    • Add a filters property to store filtering criteria for each tag group
    • Extend configuration to accept filter definitions
  2. In app/formatters/SummaryHtml/Formatter.ts:

    • Override _generateAggregationLines method to apply filters
    • Add filter processing logic before HTML conversion
    • Preserve existing showdown conversion functionality

Test:

  1. In app/formatters/SummaryHtml/Formatter.test.ts, add:
    • Test filtering worklogs by tag value
    • Test filtering with multiple criteria
    • Test empty filter behavior
    • Test invalid filter handling
    • Test HTML output with filtered groups

Example test cases:

test('filters worklog entries by tag value')
test('applies multiple filters to grouped entries')
test('handles empty filters gracefully')
test('maintains HTML structure with filtered groups')

Description

This pull request introduces a new filtering mechanism for the SummaryHtml formatter that enables users to apply custom filters to worklog entries based on tag groups. The changes include:

  • Adding a new TagGroupFilter type that allows defining filters for specific tag combinations
  • Extending the SummaryHtmlFormatterConfiguration to support these new filters
  • Implementing filter application logic in the SummaryHtmlFormatter to selectively include or exclude worklog entries
  • Creating comprehensive test cases to validate the new filtering functionality

The filtering mechanism allows for complex filtering scenarios, such as:

  • Filtering entries by specific tag values
  • Applying multiple filters to a tag group
  • Maintaining the existing HTML report structure when filters are applied

Summary

  • Added FilterFunction and TagGroupFilter types to SummaryHtmlFormatterConfiguration
  • Enhanced SummaryHtmlFormatter with filter application methods
  • Implemented new test cases in Formatter.test.ts
  • Supports flexible worklog entry filtering based on tag groups
  • Maintains existing HTML report generation logic

Fixes

Fixes #2061. Continue the conversation here: https://app.sweep.dev/c/86d4e4c1-1999-4a83-b3e1-3236531d8135.

To have Sweep make further changes, please add a comment to this PR starting with "Sweep:".

📖 For more information on how to use Sweep, please read our documentation.

Tracking ID: 763187f40e

Copy link
Contributor Author

sweep-ai bot commented Jan 8, 2025

Hey @AlphaGit, CI auto-fix is currently not enabled for you. Please reach out to the Sweep team to enable it.

📖 For more information on how to use Sweep, please read our documentation.

Tracking ID: 763187f40e-ci-0

Copy link

coderabbitai bot commented Jan 8, 2025

Walkthrough

The pull request introduces filtering capabilities to the SummaryHtml formatter. This enhancement allows filtering of worklog entries within tag groupings by adding new configuration options, methods, and type definitions. The changes span three files: the formatter configuration, the formatter itself, and its test suite. The implementation enables more granular control over worklog entry selection through tag-based and custom filter functions while maintaining the existing HTML generation process.

Changes

File Change Summary
app/formatters/SummaryHtml/SummaryHtmlFormatterConfiguration.ts - Added FilterFunction type for worklog filtering
- Added TagGroupFilter type for tag group filtering
- Updated constructor to support optional filters
app/formatters/SummaryHtml/Formatter.ts - Added _generateAggregationLines method for filtered worklog processing
- Implemented _applyFilters method for tag and custom filtering
- Added _arraysHaveSameElements utility method
- Modified format method with additional logging
app/formatters/SummaryHtml/Formatter.test.ts - Added test suite for filtering worklog entries
- Included tests for tag-based filtering
- Verified behavior with multiple filters and edge cases

Sequence Diagram

sequenceDiagram
    participant Config as SummaryHtmlFormatterConfiguration
    participant Formatter as SummaryHtmlFormatter
    participant Worklogs as Worklog[]

    Config->>Formatter: Initialize with tags and filters
    Formatter->>Worklogs: Apply filters
    Worklogs-->>Formatter: Filtered worklog entries
    Formatter->>Formatter: Generate HTML aggregation lines
    Formatter-->>Config: Formatted HTML summary
Loading

Assessment against linked issues

Objective Addressed Explanation
Add filters to SummaryHtml formatter configuration [#2061]
Override _generateAggregationLines with filter logic [#2061]
Preserve showdown conversion functionality [#2061]
Test filtering by tag value [#2061]
Test multiple filter criteria [#2061]

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4068471 and cbfea00.

📒 Files selected for processing (3)
  • app/formatters/SummaryHtml/Formatter.test.ts (1 hunks)
  • app/formatters/SummaryHtml/Formatter.ts (1 hunks)
  • app/formatters/SummaryHtml/SummaryHtmlFormatterConfiguration.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@AlphaGit
Copy link
Owner

AlphaGit commented Jan 8, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Jan 8, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sweep: Add a filter to each grouping in the SummaryHtml formatter
1 participant