Skip to content

Commit

Permalink
Handle the corner case when there are no user inputs
Browse files Browse the repository at this point in the history
If the user has never submitted an input, we can't infer anything.
So we return early.
This fixes #829 (comment)
  • Loading branch information
shankari committed Jul 27, 2021
1 parent f573248 commit f2060cc
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def placeholder_predictor_demo(trip):
import emission.core.get_database as edb
user = trip["user_id"]
unique_user_inputs = edb.get_analysis_timeseries_db().find({"user_id": user}).distinct("data.user_input")
if len(unique_user_inputs) == 0:
return []
random_user_input = random.choice(unique_user_inputs) if random.randrange(0,10) > 0 else []

logging.debug(f"In placeholder_predictor_demo: ound {len(unique_user_inputs)} for user {user}, returning value {random_user_input}")
Expand Down

0 comments on commit f2060cc

Please sign in to comment.