Skip to content

Conversation

@santhoshJus
Copy link
Contributor

@santhoshJus santhoshJus commented Sep 25, 2025

Added tools for refund analytics and to filter orders by amount.

Fetching details from kvrefundtxns for refund analytics similar to how it was implemented in lighthouse

@coderabbitai
Copy link

coderabbitai bot commented Sep 25, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds two new analytics tools in app/agents/voice/automatic/tools/juspay/analytics.py: functions for refund analytics by time and orders filtered by amount. Introduces corresponding FunctionSchema entries, updates the tools registry, and maps function names in the tool_functions dictionary for runtime invocation and callback handling.

Changes

Cohort / File(s) Summary of Changes
New analytics tool functions
app/agents/voice/automatic/tools/juspay/analytics.py
Added async def get_refund_analytics_by_time(params) to fetch refund analytics with dimensions/time; added async def get_orders_by_amount(params) to query orders by amount/operator; both handle API calls, errors, and result callbacks.
Function schemas
app/agents/voice/automatic/tools/juspay/analytics.py
Added get_refund_analytics_function = FunctionSchema(...) and get_orders_by_amount_function = FunctionSchema(...) to expose the new tools with required inputs.
Tooling registry and mappings
app/agents/voice/automatic/tools/juspay/analytics.py
Included both new schemas in ToolsSchema(standard_tools=[...]); added "get_refund_analytics_by_time": get_refund_analytics_by_time and "get_orders_by_amount": get_orders_by_amount to tool_functions.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor VoiceAgent as Voice Agent
  participant Tools as Tools Registry
  participant JuspayTool as Juspay Analytics Tool
  participant JuspayAPI as Juspay API
  participant Callback as Result Callback

  rect rgb(240, 245, 255)
    Note over VoiceAgent,Tools: Invoke refund analytics by time
    VoiceAgent->>Tools: call("get_refund_analytics_by_time", params)
    Tools->>JuspayTool: get_refund_analytics_by_time(params)
    JuspayTool->>JuspayAPI: GET /refunds/analytics?time&dimensions
    JuspayAPI-->>JuspayTool: response (data or error)
    alt success
      JuspayTool->>Callback: on_result(data)
      JuspayTool-->>Tools: data
    else error
      JuspayTool->>Callback: on_error(error)
      JuspayTool-->>Tools: error
    end
  end

  rect rgb(240, 255, 240)
    Note over VoiceAgent,Tools: Invoke orders by amount
    VoiceAgent->>Tools: call("get_orders_by_amount", params)
    Tools->>JuspayTool: get_orders_by_amount(params)
    JuspayTool->>JuspayAPI: GET /orders?amount&operator&time
    JuspayAPI-->>JuspayTool: response (grouped by payment method)
    alt success
      JuspayTool->>Callback: on_result(data)
      JuspayTool-->>Tools: data
    else error
      JuspayTool->>Callback: on_error(error)
      JuspayTool-->>Tools: error
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I thump my paws—new charts take flight,
Refund moons and order lights,
Grouped by time, by tender’s tune,
Numbers hop from API to noon.
In fields of logs, I nibble byte—
Tools now bloom; all metrics right. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately reflects the primary additions in the changeset by naming the two new tools—refund analytics and order filtering by amount—and does so in a clear, concise sentence that a teammate reviewing history would immediately understand.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2b39c3 and bc754f6.

📒 Files selected for processing (1)
  • app/agents/voice/automatic/tools/juspay/analytics.py (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/agents/voice/automatic/tools/juspay/analytics.py (1)
app/agents/voice/automatic/types/models.py (1)
  • ApiFailure (32-35)
🪛 Ruff (0.13.1)
app/agents/voice/automatic/tools/juspay/analytics.py

544-544: Do not catch blind exception: Exception

(BLE001)


577-577: Do not catch blind exception: Exception

(BLE001)

@murdore
Copy link
Collaborator

murdore commented Oct 1, 2025

@santhoshJus this needs to be added in ligthouse. we will be moving to consuming tools from lighthouse via sse

@santhoshJus
Copy link
Contributor Author

Added tool in lighthouse: BZ-44883: feat: Added tool to filter orders by amount

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants