Support multiple difficulty and pattern filters#4
Merged
Conversation
FilterProblems now accepts []string slices for both difficulties and
tags. A problem passes if its difficulty matches any of the supplied
values, and if it carries any of the supplied tag slugs. Empty slices
mean "no filter" (all included), same as before.
CLI: --difficulty and --tag now use a custom multiFlag type that
accepts repeated flags or comma-separated values, or any combination:
--difficulty easy --difficulty hard
--difficulty easy,hard
--tag dp --tag backtracking
HTTP server: /api/quiz/start now reads {"difficulties":[...],"tags":[...]}
instead of single-value {"difficulty":"...","tag":"..."}.
Browser UI: difficulty buttons now toggle independently (multi-select)
instead of being mutually exclusive. Pattern selection is a scrollable
checkbox list instead of a single dropdown. In both cases, leaving all
unselected means all are included.
Tests: existing FilterProblems tests updated to pass slices; two new
tests added — TestFilterByMultipleDifficulties and
TestFilterByMultipleTags — plus a combined multi-difficulty+multi-tag
test.
https://claude.ai/code/session_01CSqri29pumwCCTp4ApU2da
The multiFlag type supported both --flag a --flag b and --flag a,b, which was more complexity than needed. Replace it with standard flag.String and a splitCSV helper that trims, lowercases, and splits on commas. Flags are now strictly CSV: --difficulty easy,hard --tag dynamic-programming,backtracking Repeated flags are no longer accepted. README examples updated to match. https://claude.ai/code/session_01CSqri29pumwCCTp4ApU2da
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR extends the filtering system to support selecting multiple difficulties and patterns simultaneously, rather than being limited to a single filter value. The change applies across the CLI, web server, and core filtering logic.
Key Changes
Core filtering logic (
quiz/quiz.go):FilterProblems()now acceptsdifficultiesandtagSlugsas slices instead of single stringsCLI (
cli/cli.go):multiFlagtype to support both repeated flags (--difficulty easy --difficulty hard) and comma-separated values (--difficulty easy,hard)--difficultyand--tagflags to use the newmultiFlagtypeWeb UI (
server/static/index.html):Server API (
server/server.go):/api/quiz/startrequest body to acceptdifficultiesandtagsarrays instead of single stringsTests (
quiz/quiz_test.go):TestFilterByMultipleDifficulties,TestFilterByMultipleTags, andTestFilterByMultipleDifficultiesAndMultipleTagsImplementation Details
nilor empty slices skips that filter category (equivalent to "all")https://claude.ai/code/session_01CSqri29pumwCCTp4ApU2da