Problem when generating little number of transactions
Closed this issue · 4 comments
gcattan commented
jorgelaranjo commented
Go to datagenerator/__main__.py
and change line 87 from
if not obj.number in (o.number for o in reponse_list):
to
if not obj.account_number in (o.account_number for o in reponse_list):
Still will not generate any useful transactions as it is missing the login for it on the module.
You can then easily add the following
def generate_transactions(regs_num: int, people_list: list, accounts_list: list) -> list:
response_list = []
while len(response_list) < regs_num:
print(f'Creating transaction {len(response_list)+1} of {regs_num}... {" "*30}', end='\r')
obj = BankTransaction.BankTransaction(account=random.choice(accounts_list), value=random.randint(1,1000), description='Transaction description')
if not obj.moment in (o.moment for o in response_list):
response_list.append(obj)
print(f'{len(response_list):,} transactions created. {" "*40}')
print(f'List of objects using {sys.getsizeof(response_list)/(10**6):.1f} MB')
return response_list
and then call it on
if db["class"] == 'BankTransaction':
moment = _dt.datetime.now() - _dt.timedelta(days=((regs//6)+1))
obj_list = generate_transactions(main_regs, people_list, accounts_list)
Using faker
you'd get the same and simpler to get what you'd like.
gcattan commented
Ok, thanks. I have pushed the modification in a PR.
What do you mean by faker
?
jorgelaranjo commented
Ok, thanks. I have pushed the modification in a PR. What do you mean by
faker
?
gcattan commented
Ok, I see. Thank you!