Jon Solow
commited on
Commit
·
6746db8
1
Parent(s):
f3db32c
Load all users from supabase on load with a retry 0.5s delay
Browse files- src/data_storage.py +10 -0
src/data_storage.py
CHANGED
@@ -1,5 +1,7 @@
|
|
|
|
1 |
from secrets import token_urlsafe
|
2 |
import streamlit as st
|
|
|
3 |
|
4 |
from queries.supabase_db.client import supabase_client
|
5 |
|
@@ -9,6 +11,14 @@ USER_ROSTERS_TABLE = "npcs_user_rosters"
|
|
9 |
TOKENS_TABLE = "npcs_tokens"
|
10 |
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
def update_selection(user_id: str | int, position_id: str, player_id: str):
|
13 |
existing_record = (
|
14 |
supabase_client.table(USER_ROSTERS_TABLE)
|
|
|
1 |
+
from postgrest.exceptions import APIError
|
2 |
from secrets import token_urlsafe
|
3 |
import streamlit as st
|
4 |
+
import time
|
5 |
|
6 |
from queries.supabase_db.client import supabase_client
|
7 |
|
|
|
11 |
TOKENS_TABLE = "npcs_tokens"
|
12 |
|
13 |
|
14 |
+
try:
|
15 |
+
all_users = supabase_client.table(USERS_TABLE).select("*").execute()
|
16 |
+
except APIError:
|
17 |
+
# automatic retry
|
18 |
+
time.sleep(0.5)
|
19 |
+
all_users = supabase_client.table(USERS_TABLE).select("*").execute()
|
20 |
+
|
21 |
+
|
22 |
def update_selection(user_id: str | int, position_id: str, player_id: str):
|
23 |
existing_record = (
|
24 |
supabase_client.table(USER_ROSTERS_TABLE)
|