feat: Add queries and accessors to fetch lead wise status#587
feat: Add queries and accessors to fetch lead wise status#587manas-narra wants to merge 1 commit intojuspay:releasefrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughA new lead status counts analytics feature is introduced across multiple application layers. The implementation spans API routing, database accessors, query builders, and schema definitions, following existing handler patterns with pagination and search capabilities. Changes
Sequence DiagramsequenceDiagram
participant Client as API Client
participant Handler as get_lead_status_counts Handler
participant Accessor as Accessor Function
participant Query as Query Builders
participant DB as Database
Client->>Handler: Request with filters, pagination options
Handler->>Handler: Validate pagination bounds & apply user scoping
Handler->>Accessor: Call get_lead_status_counts_from_db(filters, page, limit, search...)
Accessor->>Query: Call get_analytics_lead_status_counts_query(...)
Query->>Query: Build WHERE clause with search filters
Query-->>Accessor: Return SQL + params
Accessor->>DB: Execute paginated query
DB-->>Accessor: Lead status counts rows
Accessor->>Query: Call get_analytics_lead_status_counts_total_query(...)
Query-->>Accessor: Return SQL + params for total count
Accessor->>DB: Execute total count query
DB-->>Accessor: Total count value
Accessor->>Accessor: Compute total_pages, format results
Accessor-->>Handler: Return structured response with pagination
Handler->>Handler: Format final response
Handler-->>Client: Return analytics with formatted results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Note: Review should pay special attention to the duplication of Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/api/routers/breeze_buddy/analytics/handlers.py (1)
687-689: Redundant ternary forshop_identifier.
row.get("shop_identifier") if row.get("shop_identifier") else Noneis equivalent torow.get("shop_identifier")sincedict.getalready returnsNoneby default when the key is missing, and a falsy value (empty string) is already mapped toNone.♻️ Simplification
- "shop_identifier": ( - row.get("shop_identifier") if row.get("shop_identifier") else None - ), + "shop_identifier": row.get("shop_identifier") or None,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/api/routers/breeze_buddy/analytics/handlers.py` around lines 687 - 689, The assignment for "shop_identifier" uses a redundant ternary; replace the expression row.get("shop_identifier") if row.get("shop_identifier") else None with a direct row.get("shop_identifier") in the code that builds the row mapping (the dict construction around "shop_identifier" in handlers.py), so the value is the same but simpler and clearer.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/database/queries/breeze_buddy/analytics.py`:
- Around line 748-756: Add a helper function _escape_ilike(value: str) that
escapes backslashes, % and _ (replace "\" -> "\\", "%" -> "\%", "_" -> "\_"),
then use it when building ILIKE parameters for search_merchant_id and
search_shop_identifier (replace values.append(f"%{...}%") with
values.append(f"%{_escape_ilike(...)}%")); also apply the same change in the
total-count query where those parameters are added, and ensure the ILIKE
expressions include an explicit ESCAPE '\\' clause so the escaped characters are
treated literally.
---
Nitpick comments:
In `@app/api/routers/breeze_buddy/analytics/handlers.py`:
- Around line 687-689: The assignment for "shop_identifier" uses a redundant
ternary; replace the expression row.get("shop_identifier") if
row.get("shop_identifier") else None with a direct row.get("shop_identifier") in
the code that builds the row mapping (the dict construction around
"shop_identifier" in handlers.py), so the value is the same but simpler and
clearer.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
app/api/routers/breeze_buddy/analytics/__init__.pyapp/api/routers/breeze_buddy/analytics/handlers.pyapp/database/accessor/breeze_buddy/analytics.pyapp/database/queries/breeze_buddy/analytics.pyapp/schemas/breeze_buddy/analytics.py
- Added queries and accessors to fetch lead wise status
a9a2724 to
6c1266a
Compare
Summary by CodeRabbit
Release Notes