Skip to content

Add an /api/event/[event id]/account/ endpoint - #82

Open
willbarton wants to merge 5 commits into
mainfrom
feature/account-list-api
Open

Add an /api/event/[event id]/account/ endpoint#82
willbarton wants to merge 5 commits into
mainfrom
feature/account-list-api

Conversation

@willbarton

@willbarton willbarton commented Jul 23, 2026

Copy link
Copy Markdown
Member

This adds an endpoint to query accounts that are in an event, returning information about accounts within an event. The API docs would look something like this:

Account list view

/api/events/{event_id}/accounts/?cons_acct_num={comma separated list of account numbers}

GET - takes a comma-separated list of account numbers and returns a JSON array of those accounts with their portfolio type, account type, and the total number of inconsistencies and total number of months of data, for a given event.

For example, a query of /api/events/1/accounts/?cons_acct_num=1234567890,2345678901 should return JSON like:

[
    {
        "cons_acct_num": "1234567890",
        "port_type": "I",
        "acct_type": "00"
        "total_inconsistencies": 1,
        "months_of_data": 5,
    },
    {
        "cons_acct_num": "2345678901",
        "port_type": "I",
        "acct_type": "00"
        "total_inconsistencies": 1,
        "months_of_data": 5,
    },
]

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Browsers

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer 8, 9, 10, and 11
  • Edge
  • iOS Safari
  • Chrome for Android

Accessibility

  • Keyboard friendly
  • Screen reader friendly

Other

  • Flexible from small to large screens
  • No linting errors or warnings
  • JavaScript tests are passing

This adds an account listing endpoint to an event that serializes the accounts within the event and annotates them with total number of inconsistencies (evaluators hit), and months of data for the account.

I've added these annotations to the `AccountActivityQuerySet` object management for `AccountActivity` (which is defined in `evaluate_m2`), so they're available on any `AccountActivity.objects` query.
This also requires a `cons_acct_num` parameter to be given, otherwise no results will be returned.
@willbarton
willbarton force-pushed the feature/account-list-api branch from 8528c53 to d9a7468 Compare July 23, 2026 16:00
@willbarton
willbarton marked this pull request as ready for review August 5, 2026 15:49
@willbarton
willbarton requested a review from schbetsy August 5, 2026 15:58

@schbetsy schbetsy 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.

Just a few small comments, otherwise this looks great. I like your implementation using manager methods. I put a question on the original ticket about exactly how we want to calculate months_of_data and total_inconsistencies, so let's wait and see about that before we merge.

Comment on lines +344 to +346
"k2",
"k4",
"l1"

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.

Is select_related necessary, since we aren't putting any of the extra segment values into the API response?


class Meta(AccountActivitySerializer.Meta):
default_fields = [
# list(AccountActivitySerializer.Meta.default_fields) + [

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.

Remove this commented line?

return J2.objects.bulk_create(j_segments)


def evaluator_result_record(

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.

This is a good idea 👍

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