fix(error-handling): catch UnboundLocalError on update
Some checks are pending
Docker / build (push) Waiting to run
Some checks are pending
Docker / build (push) Waiting to run
Ensure robustness in `update_database` by catching and handling `UnboundLocalError` to avoid potential crashes during data processing. This change mitigates risks where an uninitialized variable might lead to exceptions, thus enhancing application stability. Also includes minor whitespace corrections for improved code readability.
This commit is contained in:
parent
e7864eeaa1
commit
250061876c
1 changed files with 3 additions and 3 deletions
|
@ -405,7 +405,7 @@ def update_dominance(data):
|
|||
if date_aux < date_aux2:
|
||||
values_mat[k][1] = dominance.dominance
|
||||
values_mat[k][0] = dominance.date
|
||||
|
||||
|
||||
df.iloc[start_row:end_row, start_col:end_col] = values_mat
|
||||
df.to_excel(DATA_FILE, sheet_name="Sheet7", index=False)
|
||||
|
||||
|
@ -442,7 +442,7 @@ def update_rank(data=None):
|
|||
if date_aux < date_aux2:
|
||||
values_mat[k][1] = rank.rank
|
||||
values_mat[k][0] = rank.date
|
||||
|
||||
|
||||
df.iloc[start_row:end_row, start_col:end_col] = values_mat
|
||||
df.to_excel(DATA_FILE, sheet_name="Sheet8", index=False)
|
||||
|
||||
|
@ -783,7 +783,7 @@ def update_database(date_from=None, date_to=None):
|
|||
data.crypto_subscriberCount = social_crypto.subscriberCount
|
||||
data.crypto_commentsPerHour = social_crypto.commentsPerHour
|
||||
data.crypto_postsPerHour = social_crypto.postsPerHour
|
||||
except Social.DoesNotExist:
|
||||
except (Social.DoesNotExist, UnboundLocalError):
|
||||
data.btc_subscriberCount = 0
|
||||
data.btc_commentsPerHour = 0
|
||||
data.btc_postsPerHour = 0
|
||||
|
|
Loading…
Reference in a new issue