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

Commit

Permalink
Bug fixed
Browse files Browse the repository at this point in the history
Fixed a bug in which if the account does not have any useable content the request didn't  fail
  • Loading branch information
Paul Goldschmidt committed Sep 25, 2021
1 parent d11b130 commit e496621
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backend/api/predict_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ def predict_party(twitter_handle):
break

except:
print("Request failed.")
return dict({"success": False, "error": 440, "data": {}, "tweetsread": 0})

return dict({"success": False, "error": 404, "data": {}, "tweetsread": 0})

for tweet in tweets:
prediction = predict.predict(tweet)
tweetsread = tweetsread + 1
Expand All @@ -63,6 +62,9 @@ def predict_party(twitter_handle):
predictions[key] = []
predictions[key].append(value)

if tweetsread == 0:
return dict({"success": False, "error": 204, "data": {}, "tweetsread": 0})

for key, value in predictions.items():
predictions[key] = statistics.mean(value)
print("Success. Downloaded and analyzed in total " +
Expand Down

0 comments on commit e496621

Please sign in to comment.