Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event object does not have Docket attribute #91

Open
hiroTochigi opened this issue Jan 7, 2021 · 2 comments
Open

event object does not have Docket attribute #91

hiroTochigi opened this issue Jan 7, 2021 · 2 comments

Comments

@hiroTochigi
Copy link
Contributor

I executed Courtbot API at my local environment, and I got an error.
Then, I found that event object does not have Docket attribute.

The below code is a part of api/views.py

@csrf_exempt
def case(request):
    if request.method == 'GET':
        year = request.GET.get('year', 'NOT PROVIDED')
        county = request.GET.get('county', 'NOT PROVIDED')
        case_num = request.GET.get('case_num', 'NOT PROVIDED')

        try:
            case = oscn.request.Case(year=year, county=county, number=case_num)
        except Exception as exc:
            print(exc)
            err_msg = (
                f'Unable to find case with the following information: '
                f'year {year}, county {county}, case number {case_num}')
            return JsonResponse({'error': err_msg})

        arraignment_event = find_arraignment_or_return_False(case.events)
------------------------------------------------------------------------------------------------------
                                                .
                                                . 
                                                .
-------------------------------------------------------------------------------------------------------
def find_arraignment_or_return_False(events):
    for event in events:
        if "arraignment" in event.Docket.lower():
            return event
    return False

The case object is returned from oscn, then its events value goes into the
find_arraignment_or_return_False() method.
Then, events is iterated as event inside the find_arraignment_or_return_False()
However, event object does not have Docket attribute.
The event object has the following attributes.

  1. Amount
  2. Code
  3. Count
  4. Date
  5. Description
  6. Party
@hiroTochigi
Copy link
Contributor Author

hiroTochigi commented Jan 19, 2021

I think that the same problem happens at https://court.bot

I will experiment various Court Case Number to see what happen

@hiroTochigi
Copy link
Contributor Author

hiroTochigi commented Jan 26, 2021

I found out that if the case like below, oscn sends back events list.
However, each event object in events list is an empty list-like object.
Then, the court bot blows up because it accesses to a Docket attribute which does not exist.
In order to handle this error, it is just to needed to handle this error.
I will make a pull request to handle this error, so at least we prevent the court bot from halting suddenly.
However, I have never encountered the an event object having Docket attribute with data even though I have encountered the event object having a Docket attribute with empty list.
I picked up case numbers from 12/2020 to 1/2021 randomly, so I will extend the duration of case number samples to the past date.

image

@hiroTochigi hiroTochigi mentioned this issue Feb 3, 2021
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

No branches or pull requests

1 participant