Skip to content

Fix unnecessary array in Stats API response#21

Merged
piobeny merged 1 commit intomainfrom
MT-21031-fix-stats-api-docs
Mar 12, 2026
Merged

Fix unnecessary array in Stats API response#21
piobeny merged 1 commit intomainfrom
MT-21031-fix-stats-api-docs

Conversation

@piobeny
Copy link
Contributor

@piobeny piobeny commented Mar 11, 2026

Motivation

Fix returned values in Stats API

Changes

  • Remove array from responses in:
  • /stats/domains
  • /stats/categories
  • /stats/email_service_providers
  • /stats/date

How to test

  • Go to API docs
  • See changes
  • Compare it with real data returned from API

Before:

[
  {
    "sending_domain_id": 3938,
    "stats": [
      {
        "delivery_count": 190,
        "delivery_rate": 0.95,
        "bounce_count": 10,
        "bounce_rate": 0.05,
        "open_count": 171,
        "open_rate": 0.9,
        "click_count": 133,
        "click_rate": 0.7,
        "spam_count": 3,
        "spam_rate": 0.02
      }
    ]
  }
]

After:

[
  {
    "sending_domain_id": 3938,
    "stats": {
      "delivery_count": 190,
      "delivery_rate": 0.95,
      "bounce_count": 10,
      "bounce_rate": 0.05,
      "open_count": 171,
      "open_rate": 0.9,
      "click_count": 133,
      "click_rate": 0.7,
      "spam_count": 3,
      "spam_rate": 0.02
    }
  }
]

Images and GIFs

N/A

Summary by CodeRabbit

Release Notes

  • API Changes
    • Four statistics endpoints have been updated to return a single consolidated statistics object instead of arrays. Affected endpoints include domains, categories, email service providers, and date-based statistics. Integrations consuming these endpoints will need to adjust their response parsing logic to accommodate the new structure.

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2e87bdb5-fb99-477b-896c-6d244dd9865b

📥 Commits

Reviewing files that changed from the base of the PR and between af2985f and 7d5deb0.

📒 Files selected for processing (1)
  • specs/email-sending.openapi.yml

📝 Walkthrough

Walkthrough

Four GET /stats endpoints in the OpenAPI specification have their response schemas modified. The stats field changed from an array of SendingStats objects to a single SendingStats object reference across the domains, categories, email_service_providers, and date statistics endpoints.

Changes

Cohort / File(s) Summary
OpenAPI Stats Endpoints Schema Update
specs/email-sending.openapi.yml
Modified response schema for stats field in four GET endpoints (/api/accounts/{account_id}/stats/domains, /categories, /email_service_providers, /date) from array type to direct object reference. Changed from type: array with items: $ref to single $ref to SendingStats schema.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A schema so simple, so clean and refined,
Four endpoints now streamlined, no arrays to bind,
Where stats used to cluster in lists all around,
A single SendingStats object shall now be found! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: removing an unnecessary array wrapper from the Stats API response fields.
Description check ✅ Passed The pull request description includes all required sections from the template with concrete examples showing the before/after response structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch MT-21031-fix-stats-api-docs

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.

@piobeny piobeny marked this pull request as ready for review March 11, 2026 10:44
@piobeny piobeny merged commit 73a0136 into main Mar 12, 2026
2 checks passed
@piobeny piobeny deleted the MT-21031-fix-stats-api-docs branch March 12, 2026 12:05
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.

4 participants