ASFHyP3/hyp3

Credits system for cost of 1

jtherrmann opened this issue · 2 comments

Before merging to develop:

  • implement dynamo.user.create_user()
  • implement dynamo.user.decrement_credits()
  • change return value of handlers.get_user() to match new openapi spec
  • update user schema in openapi spec to replace quota with credits
  • update job schema in openapi spec to include cost
  • make sure priority starts at 9,999
  • save important Users table records, then delete all records and re-create the important ones after merging
  • fix failing tests
  • add/update tests to reflect new requirements and perform manual test coverage review
  • generate test coverage report to see if we missed adding/updating tests?
  • TODO items in code
  • Run a git grep -i for terms such as "quota" and "month" and either rename them or leave TODOs where the business logic needs to change; initial implementation should have no concept of monthly credit allotment
  • Option to reset users' credits to 10,000 each month
  • Address certain race conditions

I reviewed all of the functions that we've added/changed/deleted as part of the credits system implementation and confirmed that test coverage is sufficient for added/changed functions and references to deleted functions have been removed:

apps/api/src/hyp3_api/handlers.py

  • changed: post_jobs
  • changed: get_user

lib/dynamo/dynamo/jobs.py

  • deleted: _get_job_count_for_month
  • added: _get_credit_cost (not tested directly)
  • deleted: get_quota_status
  • changed: put_jobs
  • deleted: _get_job_priority
  • added: _prepare_job_for_database (not tested directly)
  • deleted: count_jobs

lib/dynamo/dynamo/user.py

  • deleted: get_user
  • deleted: get_priority
  • added: get_or_create_user
  • deleted: get_max_jobs_per_month
  • added: _get_current_month (mocked, not tested)
  • added: _create_user
  • added: _reset_credits_if_needed
  • added: decrement_credits

Closing this issue and tracking remaining TODOs at #2055