feat: flatmates matching/profiles enhancements and property search updates#14
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
📝 WalkthroughWalkthroughThis PR introduces a new outgoing likes feature, improves user discovery filtering, optimizes database connection pooling, and hardens property search result handling. The changes add a ChangesSwipe Interaction Tracking & Outgoing Likes
Infrastructure & Robustness Improvements
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review Summary by QodoAdd outgoing likes endpoint and improve profile discovery filtering
WalkthroughsDescription• Add outgoing likes endpoint to track profiles user has liked • Exclude already-swiped profiles from discoverable list • Harden property search with type-safe float conversions • Tune database pool configuration for production performance Diagramflowchart LR
A["User Swipes Profile"] --> B["Record in UserSwipe"]
B --> C["GET /outgoing-likes"]
C --> D["list_outgoing_likes Service"]
D --> E["Return Liked Profiles"]
F["Profile Discovery"] --> G["Exclude Swiped Users"]
G --> H["Cleaner Results"]
I["Property Search"] --> J["Type-safe Float Conversion"]
J --> K["Error Handling"]
File Changes1. app/api/api_v1/endpoints/flatmates.py
|
Code Review by Qodo
1.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
app/services/flatmates/profiles.py (1)
81-85: ⚡ Quick winUse
SwipeTargetType.user.valueinstead of hardcoded"user"in the subquery filter.This avoids silent breakage if enum values change and keeps filter semantics aligned with the rest of the flatmates services.
Suggested diff
from app.models.enums import ( FlatmatesProfileStatus, PropertyPurpose, PropertyType, + SwipeTargetType, ) @@ - UserSwipe.target_type == "user", + UserSwipe.target_type == SwipeTargetType.user.value,🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/services/flatmates/profiles.py` around lines 81 - 85, Replace the hardcoded string "user" in the UserSwipe filter with the enum value to avoid brittle checks: update the subquery that builds swiped_subq (select(UserSwipe.target_user_id).where(...)) to use SwipeTargetType.user.value for the UserSwipe.target_type comparison (ensure SwipeTargetType is imported where profiles.py references UserSwipe).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/services/flatmates/profiles.py`:
- Line 69: Move the UserSwipe import out of the function-local/late import and
place "from app.models.users import UserSwipe" with the other top-level imports
in app/services/flatmates/profiles.py to avoid per-call import overhead and
satisfy E402; if a circular import prevents moving it, keep the late import but
add "# noqa: E402 # circular import with app.models.users; imported late to
avoid import cycle" and a short comment referencing the module that causes the
cycle so the rationale is documented.
In `@app/services/property/search.py`:
- Around line 609-610: The guard "if prop:" can let non-Property truthy values
through and the call cast(Property, prop) is SQLAlchemy's SQL cast, not a Python
type hint; replace this with an explicit runtime type check and remove the
SQLAlchemy cast: check isinstance(prop, Property) before appending to the
properties list (referencing the local variable prop and the properties list in
search.py) and simply append the prop when it is a real Property instance so
downstream code receives a real model object rather than a cast expression.
---
Nitpick comments:
In `@app/services/flatmates/profiles.py`:
- Around line 81-85: Replace the hardcoded string "user" in the UserSwipe filter
with the enum value to avoid brittle checks: update the subquery that builds
swiped_subq (select(UserSwipe.target_user_id).where(...)) to use
SwipeTargetType.user.value for the UserSwipe.target_type comparison (ensure
SwipeTargetType is imported where profiles.py references UserSwipe).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 013ac804-df32-424d-ad29-7ae3824d71e4
📒 Files selected for processing (6)
app/api/api_v1/endpoints/flatmates.pyapp/core/config.pyapp/services/flatmates/__init__.pyapp/services/flatmates/matching.pyapp/services/flatmates/profiles.pyapp/services/property/search.py
There was a problem hiding this comment.
No issues found across 6 files
Auto-approved: The changes add a read-only outgoing-likes endpoint following the same pattern as existing incoming-likes, exclude already-swiped profiles from discovery to reduce duplicate suggestions, harden property search result parsing with type-safe float conversions and exception handling, and tune DB...
Re-trigger cubic
CI Feedback 🧐A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Requires human review: The PR introduces a new outgoing-likes endpoint, modifies discovery filtering, refactors property search mapping, and tunes DB config—these changes touch core business logic and require human review to ensure correctness and performance.
Re-trigger cubic
Summary
Changes
Summary by cubic
Adds an endpoint to view profiles you’ve liked and updates discovery to hide already-swiped users. Fixes an N+1 in outgoing likes, improves property search casting with debug logging, and tunes DB pool settings for steadier production performance.
New Features
Refactors
SwipeTargetTypeenum.Written for commit 55112a8. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
New Features
Bug Fixes & Improvements
Greptile Summary
This PR adds a GET
/flatmates/outgoing-likesendpoint so users can see who they've liked, filters out already-swiped profiles from discovery, hardens property-search row extraction withfloat()casts and try/except, and tunes DB pool settings for production.list_outgoing_likescorrectly batches block lookups into two queries rather than per-row calls, avoiding the N+1 pattern that still exists inlist_incoming_likes.swiped_subqis a SQL subquery applied at the DB level, so pagination of discoverable profiles remains correct; the filter intentionally excludes both likes and dislikes.float()wrapping and exception handling prevents score-field parse errors from breaking the response; theprop = row[0]fast path is a reasonable optimization for the common case.Confidence Score: 5/5
Safe to merge — all changes are additive or defensive, with no correctness regressions on existing paths.
The new outgoing-likes function correctly batches block queries, the discovery filter is applied as a SQL subquery so main-list pagination is unaffected, and the property-search hardening only adds safety around score-field extraction. The only notable trade-off is that paginated block-filtering in Python can return short pages, but that is a pre-existing pattern also present in list_incoming_likes and not a new regression.
app/services/flatmates/matching.py — the pagination behaviour under block filtering is worth a follow-up, particularly if blocked-user counts grow in production.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Client participant Router as flatmates.py (router) participant SvcOut as list_outgoing_likes participant SvcDisc as list_discoverable_profiles participant DB Client->>Router: "GET /outgoing-likes?limit&offset" Router->>SvcOut: list_outgoing_likes(db, user_id) SvcOut->>DB: "SELECT UserSwipe WHERE user_id=X AND is_liked=True (paged)" SvcOut->>DB: "SELECT blocked_user_id WHERE blocker=user_id" SvcOut->>DB: "SELECT blocker_user_id WHERE blocked=user_id" SvcOut-->>Router: filtered list[dict] (excluded_ids removed in Python) Router-->>Client: list[IncomingLikeSummary] Client->>Router: GET /discover Router->>SvcDisc: list_discoverable_profiles(db, user_id) SvcDisc->>DB: SELECT blocked/blocker ids SvcDisc->>DB: SELECT User WHERE id NOT IN (swiped_subq) AND id NOT IN (excluded) paged SvcDisc-->>Router: paginated profiles Router-->>Client: list[profile]Reviews (2): Last reviewed commit: "fix: address PR review comments - import..." | Re-trigger Greptile