fix(filters): onSale chip gap + ESLint regressions from main#662
Conversation
Auditoria exaustiva do módulo de catálogo — correções seguras e isoladas: 1. useProductImages.fetchProductImagesBatch: usa filtro IN(product_id) em chunks (80) em vez de baixar a tabela product_images inteira (limit 5000) e filtrar em memória — evita transferir milhares de linhas e o truncamento silencioso pelo teto de limit. 2/14/26. product-sorting: comparador único compareNamePtBR (Intl.Collator pt-BR, numeric + sensitivity base) — "Caneta 2" antes de "Caneta 10", acentuação consistente. Tie-break por id em todos os modos → ordem determinística entre páginas no infinite scroll. Aliases name-asc/ name-desc tratados explicitamente (antes caíam no no-op default), tanto no sorter quanto no orderBy server-side do productService. 4/28. useFiltersPageState: valida priceRange e minStock vindos da URL (NaN guard + clamp min<=max) — antes ?priceMin=abc zerava a lista sem feedback. sortBy da URL só é aceito se for um valor conhecido. 20. useFiltersPageState: filtro de Técnicas só conta como ativo / exibe chip / filtra quando há metadata.techniques nos produtos. Antes era um no-op que ainda contava no badge e mostrava chip (falso positivo). 5/10. Migração add_catalog_sort_indexes: índices parciais (WHERE active) para sale_price, created_at DESC e stock_quantity DESC — colunas de ordenação do catálogo que não tinham índice. Já aplicada no projeto. Testes unitários adicionados para o collator pt-BR, aliases de nome e tie-break determinístico. Gates TSC (0 erros) e ESLint baseline (0) verdes. https://claude.ai/code/session_01E14WrLRzQUQpeRs9sFV2uk
…rom main - useFiltersPageState: onSale was counted in activeFiltersCount but had no corresponding chip in activeFiltersSummary — users could not remove it via the removable-filter UI. Added "Em Oferta / Sim" summary entry. - ProductCard, useMobileSidebarFix: add eslint-disable-next-line for react-hooks/exhaustive-deps where omission is intentional (granular deps vs whole object; route-change-only trigger). - ThemeInitializer.test, useCatalogPrefetch.test: add eslint-disable-next-line for no-explicit-any on vitest mock casts (standard test-mocking pattern). All 4 files were introduced by main-branch commits after the baseline was generated; these suppress the regressions without changing runtime behavior. https://claude.ai/code/session_01E14WrLRzQUQpeRs9sFV2uk
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 34 minutes and 16 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Summary
Bugs found during exhaustive testing of the quick-wins implemented in #644.
useFiltersPageState.ts):onSalewas counted inactiveFiltersCount(+1 to the badge) but had no entry inactiveFiltersSummary— users could not remove the "Em Oferta" filter via the removable-chip UI. Added the missing chip entry.as any, andreact-hooks/exhaustive-depswhere the omission is deliberate and documented).What was exhaustively tested (and found OK)
fetchProductImagesBatch— chunked IN()CHUNK_SIZE=80; deduplication worksIntl.Collator('pt-BR', { numeric, sensitivity:'base' })compareNamePtBRnull/undefined safetyname-asc/name-descswitch casesbyNameThenId/withIdTiebreakpriceRangevalidation (NaN, negative, min>max)sortBywhitelist (VALID_SORT_VALUES)techniquesDataAvailableguard20260604000003_*Test plan
?onSale=1in URL on Filtros page → verify "Em Oferta" chip appears and is removablehttps://claude.ai/code/session_01E14WrLRzQUQpeRs9sFV2uk
Generated by Claude Code
Summary by cubic
Fixes the missing on-sale removable chip and hardens filter URL parsing, while making sorting correct and stable. Also speeds up catalog queries with chunked image fetching and new partial DB indexes.
Bug Fixes
onSale; validatepriceRange/minStockfrom URL (NaN, negatives, min>max); accept only knownsortBy; show/count Techniques only when product data actually has techniques.name-asc/name-desc; add deterministic id tiebreak across modes; alignproductServiceorderBy for name asc/desc.react-hooks/exhaustive-depscases.Performance
sale_price,created_at DESC, andstock_quantity DESCto accelerate catalog sorts.Written for commit d762b01. Summary will update on new commits.