potpie icon indicating copy to clipboard operation
potpie copied to clipboard

Add Sort Parameters for Conversations API

Open dhirenmathur opened this issue 8 months ago • 0 comments

Description

Currently, the conversations API does not provide a way to sort the returned conversations. Users need the ability to sort conversations by different fields and ordering to easily find the conversations they're looking for.

Current Behavior

The current API returns conversations without any sorting options, making it difficult for users to find specific conversations, especially when they have many of them.

Expected Behavior

Add two query parameters to the conversations list API endpoint:

  1. sort - Field to sort by (supports updated_at or created_at)
  2. order - Direction of sort (asc or desc)

Proposed Implementation

  1. Add query parameters to the API endpoint that lists conversations:

    • sort: Accepts values updated_at or created_at (default to created_at if not specified)
    • order: Accepts values asc or desc (default to desc if not specified)
  2. Update the database query to include the appropriate ORDER BY clause based on these parameters

Code Location

  • app/modules/conversations/conversations_router.py
  • Relevant function: List conversations endpoint

dhirenmathur avatar Apr 14 '25 15:04 dhirenmathur