mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-06 05:23:08 +00:00
Implements comprehensive improvements to the two-phase query optimization: - **Ordering Stability**: Use CTE with VALUES clause to preserve exact Phase 1 ordering Prevents any ordering discrepancies between Phase 1 ID selection and Phase 2 data fetch - **Defensive ID Validation**: Filter IDs for type safety before Phase 2 query Ensures only valid positive integers are used in the CTE - **Performance Metrics**: Add detailed logging with phase1Ms, phase2Ms, totalMs Enables monitoring and quantifying the optimization benefits - **DRY Principle**: Extract buildMetadataFilterConditions helper method Eliminates code duplication between searchTemplatesByMetadata and getMetadataSearchCount - **Comprehensive Testing**: Add 4 integration tests covering: - Basic two-phase query functionality - Ordering stability with same view counts - Empty results early exit - Defensive ID validation All tests passing (36/37, 1 skipped) Build successful 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>