Spaces:
Sleeping
Sleeping
Commit
·
174d220
1
Parent(s):
b7c9382
enhance
Browse files
app.py
CHANGED
|
@@ -5,6 +5,8 @@ import uuid
|
|
| 5 |
from datetime import datetime
|
| 6 |
from pathlib import Path
|
| 7 |
|
|
|
|
|
|
|
| 8 |
import pandas as pd
|
| 9 |
import pytz
|
| 10 |
import streamlit as st
|
|
@@ -138,6 +140,7 @@ def submit_prediction(
|
|
| 138 |
predicted_winner,
|
| 139 |
predicted_motm,
|
| 140 |
bid_points,
|
|
|
|
| 141 |
max_bid_points
|
| 142 |
):
|
| 143 |
|
|
@@ -151,7 +154,7 @@ def submit_prediction(
|
|
| 151 |
st.error("Prediction submission time has passed. Predictions can't be submitted after match start.")
|
| 152 |
return
|
| 153 |
|
| 154 |
-
if bid_points > max_bid_points or bid_points
|
| 155 |
st.error(f"Oops, invalid bid! You must bid at least 10% and not more than 50% of your points. Maximum allowed: {max_bid_points}")
|
| 156 |
# st.error(f"Oops! 🙈 Looks like you're going overboard with your bid points! Your bid points cannot exceed your total points. Maximum allowed bid points: {max_bid_points} 😱")
|
| 157 |
return
|
|
@@ -213,8 +216,8 @@ def get_user_total_points(user_name):
|
|
| 213 |
|
| 214 |
def calculate_min_max_bid_points(user_name):
|
| 215 |
total_points = get_user_total_points(user_name)
|
| 216 |
-
min_bid_points =
|
| 217 |
-
max_bid_points =
|
| 218 |
return min_bid_points, max_bid_points
|
| 219 |
|
| 220 |
|
|
@@ -258,14 +261,14 @@ def user_selection_and_prediction():
|
|
| 258 |
|
| 259 |
bid_points = st.number_input(
|
| 260 |
"Bid Points",
|
| 261 |
-
min_value=
|
| 262 |
-
max_value=
|
| 263 |
-
value=
|
| 264 |
format="%d"
|
| 265 |
)
|
| 266 |
|
| 267 |
if st.button("Submit Prediction"):
|
| 268 |
-
submit_prediction(user_name, match_id, predicted_winner, predicted_motm, bid_points, max_bid_points)
|
| 269 |
else:
|
| 270 |
st.write("No matches are scheduled for today.")
|
| 271 |
|
|
|
|
| 5 |
from datetime import datetime
|
| 6 |
from pathlib import Path
|
| 7 |
|
| 8 |
+
import math
|
| 9 |
+
|
| 10 |
import pandas as pd
|
| 11 |
import pytz
|
| 12 |
import streamlit as st
|
|
|
|
| 140 |
predicted_winner,
|
| 141 |
predicted_motm,
|
| 142 |
bid_points,
|
| 143 |
+
min_bid_points,
|
| 144 |
max_bid_points
|
| 145 |
):
|
| 146 |
|
|
|
|
| 154 |
st.error("Prediction submission time has passed. Predictions can't be submitted after match start.")
|
| 155 |
return
|
| 156 |
|
| 157 |
+
if bid_points > max_bid_points or bid_points < min_bid_points:
|
| 158 |
st.error(f"Oops, invalid bid! You must bid at least 10% and not more than 50% of your points. Maximum allowed: {max_bid_points}")
|
| 159 |
# st.error(f"Oops! 🙈 Looks like you're going overboard with your bid points! Your bid points cannot exceed your total points. Maximum allowed bid points: {max_bid_points} 😱")
|
| 160 |
return
|
|
|
|
| 216 |
|
| 217 |
def calculate_min_max_bid_points(user_name):
|
| 218 |
total_points = get_user_total_points(user_name)
|
| 219 |
+
min_bid_points = math.ceil(total_points * 0.10) # round up
|
| 220 |
+
max_bid_points = math.floor(total_points * 0.50) # round down
|
| 221 |
return min_bid_points, max_bid_points
|
| 222 |
|
| 223 |
|
|
|
|
| 261 |
|
| 262 |
bid_points = st.number_input(
|
| 263 |
"Bid Points",
|
| 264 |
+
min_value=min_bid_points,
|
| 265 |
+
max_value=max_bid_points,
|
| 266 |
+
value=min_bid_points,
|
| 267 |
format="%d"
|
| 268 |
)
|
| 269 |
|
| 270 |
if st.button("Submit Prediction"):
|
| 271 |
+
submit_prediction(user_name, match_id, predicted_winner, predicted_motm, bid_points, min_bid_points, max_bid_points)
|
| 272 |
else:
|
| 273 |
st.write("No matches are scheduled for today.")
|
| 274 |
|