Skip to content

Commit

Permalink
ADD starting timestamp Closes #88
Browse files Browse the repository at this point in the history
  • Loading branch information
aranas committed May 24, 2024
1 parent 99fc5a9 commit 48221ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions webapp/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
COLLECTION_NAME_ENV: str = "COLLECTION_NAME"

# Application management
START_TIMESTAMP_STATE_KEY: str = "start_timestamp"
USER_ID_STATE_KEY: str = "_id"
SURVEY_SUBMITTED_STATE_KEY: str = "survey_submitted"
ERROR_MESSAGES_STATE_KEY: str = "error_messages"
Expand Down Expand Up @@ -98,6 +99,7 @@

# TODO(cptanalastriste): Refactor. There's a better way of doing this.
ALL_SESSION_KEYS: list[str] = ALL_CONSENT_STATE_KEYS + [
START_TIMESTAMP_STATE_KEY,
USER_ID_STATE_KEY,
SECTOR_STATE_KEY,
LOCATION_STATE_KEY,
Expand Down
5 changes: 5 additions & 0 deletions webapp/pages/02_1_-_Community.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import streamlit as st
from st_pages import hide_pages
from datetime import datetime

from streamlit_utils import (
verify_user,
Expand All @@ -9,6 +10,7 @@
from streamlit_extras.switch_page_button import switch_page
from survey_questions import questions
from config import (
START_TIMESTAMP_STATE_KEY,
SECTOR_STATE_KEY,
LOCATION_STATE_KEY,
ROLE_STATE_KEY,
Expand Down Expand Up @@ -48,6 +50,9 @@
verify_user(COMMUNITY_PAGE)
display_error_messages()

## Record start time (to later compute total duration)
st.session_state[START_TIMESTAMP_STATE_KEY] = str(datetime.today().replace(microsecond=0))

# reintroduce sidebar (collapse button will stay hidden as CSS cannot by
# dynamically altered)
st.set_page_config(initial_sidebar_state="expanded")
Expand Down

0 comments on commit 48221ea

Please sign in to comment.