Skip to content

FECFILE-3112: Switch to using Python built-in statistics, nicen up output#2032

Merged
lbeaufort merged 3 commits into
developfrom
feature/3112-get_overview-fix
May 14, 2026
Merged

FECFILE-3112: Switch to using Python built-in statistics, nicen up output#2032
lbeaufort merged 3 commits into
developfrom
feature/3112-get_overview-fix

Conversation

@danguyf
Copy link
Copy Markdown
Contributor

@danguyf danguyf commented May 8, 2026

Ticket link:
https://fecgov.atlassian.net/browse/FECFILE-3112

Related PRs:
N/A

Explanation for error being addressed in the ticket.

@lbeaufort
Copy link
Copy Markdown
Member

@danguyf thanks for working on this! When I run this locally using your branch (without adding any data manually), I get the following error:

./manage.py get_overview
STARTING get_overview command
[info     ] Number of committees: 3                                     
[info     ] Number of users: 3                                          
[info     ] Number of reports: 0                                        
[info     ] Number of reports per committee:                            
[info     ]    Mean: 0                                                  
[info     ] Number of transactions per committee:                       
[info     ]    Mean: 0                                                  
FAILED to execute get_overview command
Traceback (most recent call last):
  File "/opt/nxg_fec/./manage.py", line 57, in <module>
    execute_from_command_line(sys.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
    ~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 420, in run_from_argv
    self.execute(*args, **cmd_options)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 464, in execute
    output = self.handle(*args, **options)
  File "/opt/nxg_fec/fecfiler/devops/management/commands/fecfile_base.py", line 33, in handle
    self.command(*args, **options)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/opt/nxg_fec/fecfiler/devops/management/commands/get_overview.py", line 40, in command
    get_num_transactions_per_committee(committee_id)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/opt/nxg_fec/fecfiler/devops/utils/common_queries.py", line 117, in get_num_transactions_per_committee
    + f'{biggest_committee.committee_id} with {highest_count} transactions'
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'committee_id'

@danguyf danguyf changed the title FECFILE-3112: Switch to using Python build-in statistics, nicen up output FECFILE-3112: Switch to using Python built-in statistics, nicen up output May 12, 2026
@danguyf
Copy link
Copy Markdown
Contributor Author

danguyf commented May 12, 2026

@danguyf thanks for working on this! When I run this locally using your branch (without adding any data manually), I get the following error:

  File "/opt/nxg_fec/fecfiler/devops/utils/common_queries.py", line 117, in get_num_transactions_per_committee
    + f'{biggest_committee.committee_id} with {highest_count} transactions'
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'committee_id'

As you said, I was able to reproduce this by restarting my docker to load the default data and then not loading test data.

I have added error handling to handle cases where there are no committees, no reports, and/or no contacts.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Copy Markdown
Contributor

@sasha-dresden sasha-dresden left a comment

Choose a reason for hiding this comment

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

This seems great. Really like how you used quantiles to solve this problem. Perfect tool for the job. Sometimes forget python has all those features built-in

@lbeaufort lbeaufort merged commit 3e5d21c into develop May 14, 2026
5 of 6 checks passed
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