feat: filter opportunities by skill - #892
Conversation
|
Reviewed. The fix itself is solid and worth landing:
On the conflict: this isn't a superficial one to auto-resolve. Resolving this needs someone to:
@ivannissimrch — since this is a substantive merge (not just adjacent lines), can you take a pass at resolving it against current |
…annissimrch/fix-opportunity-filters-overwrite
|
I resolved against the current develop, kept getTypeWhere/getAppointmentDateWhere and the appointment param untouched, re-applied the shared deal object inside the new shape, and merged both test files into one describe block |
…sion test Code review follow-up on this PR: - The four deal-filter spreads are now built via a getDealWhere() accumulator (mirroring get-volunteer-where.ts's identical dealFilter pattern) instead of inline nested spreads gated by a redundant OR condition. Behaviorally identical (same output shape for every existing test), but structurally immune to the exact key-collision bug this PR fixes — a 5th filter can't accidentally reintroduce it by copying the old shape. - Added a test that encodes the issue's own literal repro (activity alone, then activity + a non-matching language) as a direct regression case, on top of the existing generic "all four combined" coverage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
need4deed
left a comment
There was a problem hiding this comment.
Reviewed independently (three finder angles + a TypeORM-source-level check on a candidate finding). The core fix is correct and well-tested — no correctness bugs in the diff. Pushed two small follow-ups on top:
- Extracted the four deal-filter branches into a
getDealWhere()accumulator, mirroringget-volunteer-where.ts's existing identical pattern — same output shape, but structurally immune to the exact key-collision bug this PR fixes (a future 5th filter can't accidentally reintroduce it). - Added a test encoding the issue's own literal repro (activity alone, then activity + a non-matching language) as a direct regression case.
One pre-existing, unrelated finding for the record (not from this PR, not blocking): opportunityListQuerySchema's additionalProperties: false in querystring.ts is mis-nested and doesn't actually restrict anything, which is why skill/activity validate at all today. Worth its own issue if not already tracked.
Thanks for the fix — this was a real, cleanly-diagnosed bug.
Description
filter[skill]was already accepted by the querystring schema and the handler type, butgetOpportunityWherenever read it, so the param was silently ignored and the filter did nothingdealSkillbranch so skill actually constrains the query. This is the BE half of fe#905dealkey from separate spreads, so the object spread replaced the previous constraint and only the last one reached the query. Combining an activity with a non-matching language returned the activity count instead of 0. Measured locally:activity alone 1, activity plus non-matching language still 1
dealobject as optional properties, so they accumulate instead of overwriting. Skill drops in as one more property rather than a fourth competing spreadRelated Issues
Closes #888
Checklist