gemini changes v1
This commit is contained in:
parent
107979f8ad
commit
d19d495ae1
2 changed files with 81 additions and 21 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"github.copilot.nextEditSuggestions.enabled": false
|
||||||
|
}
|
||||||
|
|
@ -40,17 +40,12 @@ else:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
# Set date to today for dataframe
|
||||||
today=date.today()
|
today=date.today()
|
||||||
df = pd.DataFrame(data,columns=cursor.column_names)
|
df = pd.DataFrame(data,columns=cursor.column_names)
|
||||||
df['date']=today
|
df['date']=today
|
||||||
|
|
||||||
# Initialize session state to keep track of the current row index
|
# function to display current row data
|
||||||
if 'current_row' not in st.session_state:
|
|
||||||
st.session_state.current_row = 0
|
|
||||||
|
|
||||||
if 'edited_df' not in st.session_state:
|
|
||||||
st.session_state.edited_df = df.copy()
|
|
||||||
|
|
||||||
def display_row(row):
|
def display_row(row):
|
||||||
st.text_input("Date", value=row['date'], key='date')
|
st.text_input("Date", value=row['date'], key='date')
|
||||||
st.text_input("Group",value=row['group'], key='group')
|
st.text_input("Group",value=row['group'], key='group')
|
||||||
|
|
@ -60,6 +55,7 @@ def display_row(row):
|
||||||
st.number_input("Reps",value=row['reps'], key='reps',format="%i")
|
st.number_input("Reps",value=row['reps'], key='reps',format="%i")
|
||||||
st.text_input("Notes",value=row['notes'], key='notes')
|
st.text_input("Notes",value=row['notes'], key='notes')
|
||||||
|
|
||||||
|
# function to save current edited row data to edited dataframe
|
||||||
def save_edited_row(index):
|
def save_edited_row(index):
|
||||||
st.session_state.edited_df.at[index,'group'] = st.session_state.group
|
st.session_state.edited_df.at[index,'group'] = st.session_state.group
|
||||||
st.session_state.edited_df.at[index,'exercise'] = st.session_state.exercise
|
st.session_state.edited_df.at[index,'exercise'] = st.session_state.exercise
|
||||||
|
|
@ -68,19 +64,82 @@ def save_edited_row(index):
|
||||||
st.session_state.edited_df.at[index,'reps'] = st.session_state.reps
|
st.session_state.edited_df.at[index,'reps'] = st.session_state.reps
|
||||||
st.session_state.edited_df.at[index,'notes'] = st.session_state.notes
|
st.session_state.edited_df.at[index,'notes'] = st.session_state.notes
|
||||||
|
|
||||||
# Display the current row of data
|
# function to save current superset row to superset dataframe
|
||||||
if st.session_state.current_row < len(df):
|
def save_superset_row(index):
|
||||||
row_data = df.iloc[st.session_state.current_row]
|
st.session_state.superset_df.at[index,'group'] = st.session_state.group
|
||||||
display_row(row_data)
|
st.session_state.superset_df.at[index,'exercise'] = st.session_state.exercise
|
||||||
else:
|
st.session_state.superset_df.at[index,'set'] = st.session_state.set
|
||||||
st.write("No more rows to display")
|
st.session_state.superset_df.at[index,'weight'] = st.session_state.weight
|
||||||
|
st.session_state.superset_df.at[index,'reps'] = st.session_state.reps
|
||||||
|
st.session_state.superset_df.at[index,'notes'] = st.session_state.notes
|
||||||
|
|
||||||
# Button to clear form and move to the next row
|
|
||||||
if st.button('Save and Next'):
|
# Build superset selector
|
||||||
if st.session_state.current_row < len(df):
|
max_superset = int(df['superset'].max()) if not df.empty else 1
|
||||||
save_edited_row(st.session_state.current_row)
|
superset_count = list(range(1, max_superset + 1))
|
||||||
st.session_state.current_row += 1
|
|
||||||
st.rerun() # Rerun the app to display the next row
|
# initialize session state dataframe
|
||||||
|
if 'edited_df' not in st.session_state or st.session_state.get('current_workout') != selected_workout:
|
||||||
|
st.session_state.edited_df = df.copy()
|
||||||
|
st.session_state.current_workout = selected_workout
|
||||||
|
st.session_state.row = 0
|
||||||
|
if 'last_superset' in st.session_state:
|
||||||
|
del st.session_state['last_superset']
|
||||||
|
keys_to_clear = ['date', 'group', 'exercise', 'set', 'weight', 'reps', 'notes']
|
||||||
|
for key in keys_to_clear:
|
||||||
|
if key in st.session_state:
|
||||||
|
del st.session_state[key]
|
||||||
|
|
||||||
|
# Initialize session state to keep track of the current row
|
||||||
|
if 'row' not in st.session_state:
|
||||||
|
st.session_state.row = 0
|
||||||
|
|
||||||
|
# set superset selection
|
||||||
|
current_superset = st.selectbox('Select Superset', options=superset_count)
|
||||||
|
|
||||||
|
# Reset row if superset changes
|
||||||
|
if 'last_superset' not in st.session_state or st.session_state.last_superset != current_superset:
|
||||||
|
st.session_state.row = 0
|
||||||
|
st.session_state.last_superset = current_superset
|
||||||
|
keys_to_clear = ['date', 'group', 'exercise', 'set', 'weight', 'reps', 'notes']
|
||||||
|
for key in keys_to_clear:
|
||||||
|
if key in st.session_state:
|
||||||
|
del st.session_state[key]
|
||||||
|
|
||||||
|
# select superset dataframe subset
|
||||||
|
subset_df = st.session_state.edited_df[st.session_state.edited_df['superset'] == current_superset]
|
||||||
|
|
||||||
|
st.write(subset_df)
|
||||||
|
|
||||||
|
# Display the current row of data
|
||||||
|
if st.session_state.row < 12 and st.session_state.row < len(subset_df):
|
||||||
|
# Get the index from the subset to update the main df later
|
||||||
|
current_idx = subset_df.index[st.session_state.row]
|
||||||
|
row_data = subset_df.loc[current_idx]
|
||||||
|
|
||||||
|
display_row(row_data)
|
||||||
|
|
||||||
|
# Button to clear form and move to the next row
|
||||||
|
if st.button('Save and Next'):
|
||||||
|
save_edited_row(current_idx)
|
||||||
|
st.session_state.row += 1
|
||||||
|
|
||||||
|
# Clear widget states so next row loads correct values
|
||||||
|
keys_to_clear = ['date', 'group', 'exercise', 'set', 'weight', 'reps', 'notes']
|
||||||
|
for key in keys_to_clear:
|
||||||
|
if key in st.session_state:
|
||||||
|
del st.session_state[key]
|
||||||
|
|
||||||
|
if st.session_state.row >= 12:
|
||||||
|
st.session_state.row = 0
|
||||||
|
st.rerun()
|
||||||
|
elif st.session_state.row >= 12 or st.session_state.row >= len(subset_df):
|
||||||
|
st.write("Superset complete")
|
||||||
|
if st.button("Start Over"):
|
||||||
|
st.session_state.row = 0
|
||||||
|
st.rerun()
|
||||||
|
|
||||||
|
st.write("Select Next Superset")
|
||||||
|
|
||||||
st.write("")
|
st.write("")
|
||||||
|
|
||||||
|
|
@ -99,5 +158,3 @@ if st.button('Save All Changes'):
|
||||||
conn.commit()
|
conn.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue