Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into dependabot/pip/sphinx-rtd-theme-1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Comeani authored Oct 10, 2023
2 parents 403e78f + 886f355 commit 30ccff4
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 42 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ updates:
schedule:
interval: "monthly"
open-pull-requests-limit: 100
groups:
python-dependencies:
patterns:
- "*"
ignore:
- dependency-name: "sphinx-jsonschema" # Newer versions of sphinx-jsonschema have compatibility issues

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CodeQL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/DocumentationBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: /usr/local/bin/entrypoint.sh

- name: Checkout project source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/PackagePublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

steps:
- name: Checkout source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/PackageTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: /usr/local/bin/entrypoint.sh

- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

[![](https://app.codacy.com/project/badge/Grade/e964afceb32c4f6ea10425e8cabd0d44)](https://www.codacy.com/gh/pitt-crc/bank/dashboard?utm_source=github.com&utm_medium=referral&utm_content=pitt-crc/bank&utm_campaign=Badge_Grade)
[![](https://app.codacy.com/project/badge/Coverage/e964afceb32c4f6ea10425e8cabd0d44)](https://www.codacy.com/gh/pitt-crc/bank/dashboard?utm_source=github.com&utm_medium=referral&utm_content=pitt-crc/bank&utm_campaign=Badge_Coverage)
[![](https://github.com/pitt-crc/bank/actions/workflows/CodeQL.yml/badge.svg)](https://github.com/pitt-crc/bank/actions/workflows/CodeQL.yml)

See the online docs: [https://pitt-crc.github.io/bank](https://pitt-crc.github.io/bank)
55 changes: 19 additions & 36 deletions bank/account_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,7 @@ def _build_usage_table(self) -> PrettyTable:
f' {recent_proposal_alloc_status}')

# Proposal End Date as first row
output_table.title = f"{self._account_name} Proposal Information"
output_table.add_row(['Proposal End Date:', proposal.end_date.strftime(settings.date_format), ""],
divider=True)

Expand Down Expand Up @@ -805,13 +806,14 @@ def _build_usage_table(self) -> PrettyTable:
output_table.add_row(['Aggregate Usage', usage_percentage, ""], divider=True)
else:
investment_total = sum(inv.service_units for inv in investments)
investment_percentage = self._calculate_percentage(aggregate_usage_total,
allocation_total + investment_total)
investment_remaining = sum(inv.current_sus for inv in investments)
investment_used = investment_total - investment_remaining
investment_percentage = self._calculate_percentage(investment_used, investment_total)

output_table.add_row(['Investment SUs', "SUs Remaining", "% Used"], divider=True)
output_table.add_row([f'**Investment SUs', "",""])
output_table.add_row([f'are applied on', "", ""])
output_table.add_row([f'any cluster to', str(investment_total)+"**", investment_percentage])
output_table.add_row([f'any cluster to', str(investment_remaining)+"**", investment_percentage])
output_table.add_row([f'cover usage above',"",""])
output_table.add_row([f'Total SUs', "", ""], divider=True)
output_table.add_row(['Aggregate Usage', usage_percentage, ""])
Expand All @@ -830,30 +832,24 @@ def _build_investment_table(self) -> PrettyTable:
if not investments:
raise MissingInvestmentError('Account has no investments')

table = PrettyTable(header=False, padding_width=5)
table.add_row(['Investment ID',
'Total Investment SUs',
'Start Date',
'Current SUs',
'Withdrawn SUs',
'Rollover SUs'])

for inv in investments:
table.add_row([
inv.id,
inv.service_units,
inv.start_date.strftime(settings.date_format),
inv.current_sus,
inv.withdrawn_sus,
inv.withdrawn_sus])
table = PrettyTable(header=False, padding_width=5, max_width=80)
table.title =f"{self._account_name} Investment Information"

for inv in investments:
table.add_row(['Investment ID','Start Date','End Date'], divider=True)
table.add_row([inv.id, inv.start_date.strftime(settings.date_format), inv.end_date.strftime(settings.date_format)], divider=True)

table.add_row(['Total Service Units', 'Current SUs', 'Withdrawn SUs'], divider=True)
table.add_row([inv.service_units, inv.current_sus, inv.withdrawn_sus], divider=True)
table.add_row(['','',''], divider=True)
return table

def info(self) -> None:
"""Print a summary of service units allocated to and used by the account"""

try:
print(self._build_usage_table())
print("\n")

except MissingProposalError as e:
print(f'Account {self._account_name} has no active proposal: {str(e)}')
Expand Down Expand Up @@ -1024,26 +1020,13 @@ def update_status(self) -> None:
continue

investment_sus_remaining = source.current_sus - total_usage_exceeding_limits
# Investment can not cover, attempt to withdraw remaining SUs in the investment
# Investment can not cover
if investment_sus_remaining < 0:
total_usage_exceeding_limits -= source.current_sus
source.current_sus = 0
continue

# TODO: This is the full amount, should it be less?
# Could use total divided by 5 to represent 5 year investment,
# while disbursement available and total_usage_exceeding_limits > 0,
# determine if usage covered like below.
source.current_sus = source.service_units - source.withdrawn_sus
source.withdrawn_sus = source.service_units

investment_sus_remaining = source.current_sus - total_usage_exceeding_limits

# Still can not cover after withdrawal
if investment_sus_remaining < 0:
total_usage_exceeding_limits -= source.current_sus
source.current_sus = 0
continue

if investment_sus_remaining >= 0:
else:
source.current_sus -= total_usage_exceeding_limits
lock_clusters = []
total_usage_exceeding_limits = 0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ crc-bank = "bank.cli.app:CommandLineApplication.execute"
[tool.poetry.dependencies]
beautifulsoup4 = "4.12.2"
pandas = "2.0.3"
prettytable = "3.8.0"
prettytable = "3.9.0"
python = ">=3.8, <4.0"
python-environ = "0.4.54"
SQLAlchemy = "2.0.19"
Expand Down

0 comments on commit 30ccff4

Please sign in to comment.