Skip to content

fix: credit cost - #187

Merged
vtnphan merged 1 commit into
devfrom
sbp-660
Sep 30, 2026
Merged

vtnphan merged 1 commit into
devfrom
sbp-660

Conversation

@vtnphan

@vtnphan vtnphan commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

SBP-660 interaction-screening and bulk-prediction (WISPS) launches never deducted credits, and the admin "SBP Credit" field had no way to show a cost for them even once fixed, since their charged quantity isn't a stored field.

Changes

  • launch_credit_cost() (credits.py) now prices bulk-prediction (multiplier × entry count) and interaction-screening (multiplier × query count × target count).
  • Added _count_wisps_samplesheet_entries() (workflows.py) to derive that quantity server-side from the samplesheet already staged for the run, instead of trusting the client-supplied fastaContent. Keeps the charge non-spoofable.
  • Added WorkflowRun.credit_cost, persisted at launch with the exact amount charged. SbpCreditField (admin.py) now reads it directly instead of recomputing from final_design_count, so the admin display works for all four workflow categories and stays accurate even if pricing changes later.
  • New migration 0a8ae645d1b3 adds workflow_runs.credit_cost. Regenerated docs/schema_diagram(.svg).

How to Test

  1. uv run pytest — covers bulk/interaction-screening deduction, 402 rejection on insufficient credits, and the persisted credit_cost value.
  2. uv run python generate_migrations.py --check to verify the migration applies cleanly.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added or updated documentation where necessary
  • I have run linting and unit tests locally
  • The code follows the project's style guidelines

@vtnphan
vtnphan marked this pull request as ready for review September 30, 2026 00:22

@amandazhuyilan amandazhuyilan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Promise me you do a test on dev after merge?

@vtnphan

vtnphan commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

Promise me you do a test on dev after merge?

Yep, will test again

@vtnphan
vtnphan merged commit 1f56b3b into dev Sep 30, 2026
3 checks passed
@vtnphan
vtnphan deleted the sbp-660 branch September 30, 2026 00:51
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