Skip to content

Display promo credits in --status output#222

Merged
zanjonke merged 2 commits into
mainfrom
feat/status-promo-credits
Jun 16, 2026
Merged

Display promo credits in --status output#222
zanjonke merged 2 commits into
mainfrom
feat/status-promo-credits

Conversation

@zanjonke

@zanjonke zanjonke commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Integrates the additive `promo_credits` field added to the `/status` endpoint in plain2code_rest_api#111, so credits granted via promo codes now appear in `plain2code.py --status`.

Promo buckets share the same shape as purchased credits (`total`, `remaining`, `expiry_date`). Changes in `cli_output/status.py`:

  • Generalized `_display_purchased_credit_line` → `_display_bucket_credit_line(bucket, label)` and reused it for both purchased (`Purchased`) and promo (`Promo`) buckets.
  • `print_status` reads `promo_credits` (via `.get(..., [])` for backward compat with older API responses) and renders each promo bucket below purchased credits.
  • `_display_status_message` now counts promo buckets when deciding whether to show "No rendering credits remaining", avoiding a false warning when a user's only remaining credits are promo credits.

Notes

  • The backend PR notes `promo_credits` depends on `CreditTransactionType.PROMO_CREDITS` and the promo migration landing on the backend `main` first.
  • No existing tests cover `cli_output/status.py`; none added here.

zanjonke added 2 commits June 15, 2026 16:35
Integrate the additive promo_credits field from the /status endpoint
(plain2code_rest_api#111). Promo buckets share the purchased-credit
shape, so the purchased-credit line renderer is generalized to take a
label and reused for both, and the no-credits-remaining check now also
considers promo buckets.
Rename test references from _display_purchased_credit_line to the
generalized _display_bucket_credit_line, pass the new promo_credits
argument to _display_status_message, and add coverage for promo
display, promo-only remaining balance, and backward compatibility when
the API omits promo_credits.
@zanjonke zanjonke requested a review from NejcS June 15, 2026 14:41
@zanjonke zanjonke self-assigned this Jun 15, 2026
@zanjonke zanjonke added the enhancement New feature or request label Jun 15, 2026

@NejcS NejcS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@zanjonke zanjonke merged commit 92faab2 into main Jun 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants