Skip to content

Please review - #2

Open
Bill-Haigh wants to merge 18 commits into
mainfrom
base
Open

Please review#2
Bill-Haigh wants to merge 18 commits into
mainfrom
base

Conversation

@Bill-Haigh

Copy link
Copy Markdown
Owner

No description provided.

@Nancy-Singleton Nancy-Singleton 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.

Looks good!

On the point about getting user input from the console - if I have misunderstood and that's not what you were looking for, I'd suggest it as a goal anyway! :)

Comment thread pyproject.toml Outdated
build-backend = "poetry.core.masonry.api"

[tool.poetry.scripts]
test = "main:Test"

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.

Nice! This was new to me

Comment thread supportbank/main.py Outdated
@@ -0,0 +1,59 @@

#! I am aware that I havent quite got there with making the scripts run correctly. WIP.
#! I am also aware that I have used a mixture of camel/snake/etc will tidy up at the end.

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.

😄

Comment thread supportbank/main.py Outdated
#! I am aware that I havent quite got there with making the scripts run correctly. WIP.
#! I am also aware that I have used a mixture of camel/snake/etc will tidy up at the end.
#TODO change to classes "accounts" and "transactions"
#TODO is there a way of passing parameters to entry points on console

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.

Not sure if I'm reading this right - are you looking to collect user input from the console? You can do that with a built in function in Python :) https://www.w3schools.com/python/python_user_input.asp

@Nancy-Singleton Nancy-Singleton 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.

Nice work with the classes :)

Next thing to try: can you run the app and accept continuous user input? I.e.:

  • You run the app with a task called something like run
  • When the app starts, it reads all the transactions from the files into memory, then asks the user for their input
  • If they say e.g. List All, then it prints the result
  • Then asks the user for their input again

@Nancy-Singleton Nancy-Singleton 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.

Looks great :)

Comment thread supportbank/main.py


class Transaction:
def __init__(self, data):

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.

I'd recommend passing in separate variables (e.g. from, narrative) rather than data - then at the point you create a new transaction (read_transactions) you can pass the right bits of data in :)

Comment thread supportbank/main.py
for idx, row in enumerate(data, start=1):
try:
if filepath.endswith(".json"):
with open(filepath, "r") as f:

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.

I think pulling out some functions called read_json_file, read_csv_file etc would be good for readability here :)

Comment thread supportbank/main.py
logger.info("Accounts and balances displayed successfully")

def list_transactions(account_name, transactions):
found = False

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.

Instead of having this found variable, you can just return early if there's no transactions, with something like this:

    transactions_for_user = [tx for tx in transactions if tx.from_account == account_name or tx.to_account == account_name]
    transactions_for_user.sort(key=lambda tx: datetime.strptime(tx.date, "%d/%m/%Y"))

    if transactions_for_user.len() == 0:
        print(f"No transactions found for account: {account_name}")
        return

    for tx in transactions_for_user:
        print(f"{tx.date} | From: {tx.from_account} | To: {tx.to_account} | {tx.narrative} | £{tx.amount:.2f}")

Comment thread supportbank/main.py
self.amount = float(amount)

@staticmethod
def normalize_date(date_str):

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.

Nice

@Nancy-Singleton

Copy link
Copy Markdown
Collaborator

How was the Copilot experience?

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.

2 participants