Skip to content

Commit

Permalink
improve bd instance, trying to fix error - pula linha
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafaelrn committed Apr 23, 2024
1 parent 9048698 commit 355aec7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/functions/bd_transaction/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import string
import time

googlecloudprofiler.start(service='bd-transaction', service_version='1.0.1', verbose=3)

def get_api_key():

Expand Down Expand Up @@ -47,20 +46,25 @@ def open_bd_bank():


line_to_insert = None
bd = None
bd_pd = None

def insert_transaction(date_trx, account, original_description, document, entity_bank, type_trx, value, balance, id_bank):

global line_to_insert
global bd
global bd_pd

print(f'Starting insert transaction - Date: {date_trx} - Account: {account} - Original Description: {original_description} - Document: {document} - Entity Bank: {entity_bank} - Type Trx: {type_trx} - Value: {value} - Balance: {balance}')
entity_bank = entity_bank.strip()

bd = open_bd_bank()
bd_pd = pd.DataFrame(bd.get_all_records(value_render_option='UNFORMATTED_VALUE'))


if line_to_insert is None:

line_to_insert = 0
bd = open_bd_bank()
bd_pd = pd.DataFrame(bd.get_all_records(value_render_option='UNFORMATTED_VALUE'))

# loop to find the first empty line
for row in bd_pd.iterrows():
Expand Down Expand Up @@ -228,6 +232,8 @@ def id_generator(size, chars=string.ascii_uppercase + string.digits):

def check(request):

googlecloudprofiler.start(service='bd-transaction', service_version='1.0.1', verbose=3)

request_json = request.get_json(silent=True)
parameters = request.args
print(f'Request JSON: {request_json}')
Expand Down

0 comments on commit 355aec7

Please sign in to comment.