Skip to content

Conversation

@AlexanderNZ
Copy link

Summary

Extracts duplicated filter-to-URLSearchParams conversion logic into a reusable buildFilterParams helper function.

Problem

Spotted some parameter building code repeated across a few functions:

  • getCatalogTechnologies
  • getOrganizationTechnologies
  • getModelObjects
  • getModelConnections

Solution

Added a single buildFilterParams(filter: Record<string, unknown>): URLSearchParams helper that handles:

  • Array values (filter[key][])
  • Null values (filter[key]=null)
  • Labels objects (filter[labels][labelKey]=value)
  • Simple string/boolean values

Changes

  • Added: buildFilterParams() helper function in src/icepanel.ts
  • Refactored: 4 functions to use the shared helper
  • Result: ~106 lines reduced to ~41 lines (65 lines removed)

Testing

  • Verified TypeScript compilation passes
  • All existing functionality preserved (filter parameters work identically)

The filter-to-URLSearchParams conversion logic was duplicated 4 times
across getCatalogTechnologies, getOrganizationTechnologies,
getModelObjects, and getModelConnections.

This extracts a buildFilterParams helper function that handles:
- Array values
- Null values
- Labels objects
- Simple string/boolean values
@AlexanderNZ AlexanderNZ closed this Dec 9, 2025
@AlexanderNZ AlexanderNZ deleted the refactor/extract-filter-params-builder branch December 9, 2025 21:24
@AlexanderNZ AlexanderNZ restored the refactor/extract-filter-params-builder branch December 9, 2025 21:29
@AlexanderNZ AlexanderNZ reopened this Dec 9, 2025
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.

1 participant