Skip to content

feat: enable Org search joined with billing Details#877

Merged
rsbh merged 40 commits intomainfrom
org_administration
Mar 7, 2025
Merged

feat: enable Org search joined with billing Details#877
rsbh merged 40 commits intomainfrom
org_administration

Conversation

@whoAbhishekSah
Copy link
Copy Markdown
Member

@whoAbhishekSah whoAbhishekSah commented Feb 26, 2025

What does this PR do?

This PR introduces a new search functionality for organizations with their associated billing information using RQL (REST Query Language) filters. The feature allows administrators to perform advanced searches across organizations with billing-related attributes through a new endpoint POST /v1beta1/admin/organizations/search.

Key Features

  • Advanced Filtering: Support for multiple filter conditions on organization and billing attributes
    • Basic operators: eq, neq, gt, gte, lt, lte
    • String specific operators: like, notlike, empty, notempty
    • List operators: in, notin
  • Group By Support: Ability to group results by specific attributes (plan_name, subscription_state, etc.)
  • Pagination: Offset and limit based pagination
  • Full-text Search: Search across multiple text fields
  • Sorting: Multi-column sorting with ascending/descending order

API Specification

Request Schema

{
  "filters": [
    { "name": "id", "operator": "neq", "value": 20 },
    { "name": "title", "operator": "like", "value": "xyz" }
  ],
  "group_by": ["plan_name"],
  "offset": 40,
  "limit": 1,
  "search": "abcd",
  "sort": [
    { "name": "title", "order": "desc" }
  ]
}

Response Schema

{
    "organizations": [
        {
            "id": "1f0d68fc-ee7d-420b-8b02-eb1479f77f0c",
            "name": "BillingTestOrg15April2024",
            "title": "BillingTestOrg15April2024",
            "created_at": "2024-04-15T12:12:11.893873Z",
            "updated_at": "2024-04-15T12:12:11.893873Z",
            "state": "enabled",
            "avatar": "",
            "created_by": "\"abhi.sah.97@gmail.com\"",
            "plan_name": "enterprise_plan",
            "payment_mode": "",
            "subscription_cycle_end_at": "2025-03-15T12:17:09Z",
            "country": "",
            "subscription_state": "past_due",
            "plan_interval": "month",
            "plan_id": "48d3ef79-3872-46ca-9759-e90a6d397f51"
        }
    ],
    "pagination": {
        "offset": 40,
        "limit": 1,
        "total_count": 0
    },
    "group": {
        "name": "plan_name",
        "data": [
            {
                "name": "enterprise_plan",
                "count": 59
            },
            {
                "name": "standard_plan",
                "count": 300
            },
            {
                "name": "N/A",
                "count": 50
            }
        ]
    }
}

Supported Fields for Operations

Filterable Fields

  • id
  • title
  • state
  • created_at
  • plan_name
  • subscription_state
  • current_period_end_at
  • plan_interval

Group By Fields

  • state
  • plan_name
  • subscription_state
  • plan_interval

Searchable Fields

  • id
  • title
  • state
  • plan_name
  • subscription_state
  • plan_interval

Implementation Details

  • Uses goqu for dynamic SQL query building
  • Implements left joins between organizations and billing-related tables
  • Handles complex queries with subqueries for latest subscription information
  • Implements proper error handling and validation
  • Uses read-only transactions for consistent data retrieval

Testing Done

  • Unit tests for query building
  • Local testing for various filter combinations
  • Edge case handling for invalid inputs

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontier ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 7, 2025 9:42am

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 26, 2025

Pull Request Test Coverage Report for Build 13717957148

Details

  • 171 of 405 (42.22%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 32.229%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/v1beta1/v1beta1.go 0 1 0.0%
pkg/server/interceptors/authorization.go 0 3 0.0%
cmd/serve.go 0 4 0.0%
core/aggregates/orgbilling/service.go 0 8 0.0%
internal/api/v1beta1/orgbilling.go 0 99 0.0%
internal/store/postgres/org_billing_repository.go 171 290 58.97%
Totals Coverage Status
Change from base Build 13714485604: 0.2%
Covered Lines: 8540
Relevant Lines: 26498

💛 - Coveralls

@whoAbhishekSah whoAbhishekSah changed the title feat: enable Org search aggregated joined with billing Details feat: enable Org search joined with billing Details Feb 27, 2025
Copy link
Copy Markdown
Member

@rsbh rsbh left a comment

Choose a reason for hiding this comment

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

🚀 LGTM 🔥

@rsbh rsbh merged commit 2c62b1f into main Mar 7, 2025
7 checks passed
@rsbh rsbh deleted the org_administration branch March 7, 2025 10:02
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.

3 participants