diff --git a/app.py b/app.py index b087dff..bd4a0c1 100644 --- a/app.py +++ b/app.py @@ -32,9 +32,9 @@ TEAMS = sorted(set(PARTICIPANTS.values())) if PARTICIPANTS else [ ] CATEGORIES = [ - ("fun_team", "π μ¬λ―Έμ"), - ("polish_team", "π μμ±λμ"), - ("utility_team", "π μ€μ©μ±μ"), + ("fun_team", "π μ¬λ―Έμ", "μμ νκΈ° 5κ°"), + ("polish_team", "π μμ±λμ", "νλ μ€νΈ 5κ°"), + ("utility_team", "π μ€μ©μ±μ", "μμ°μ° 5κ°"), ] @@ -117,7 +117,7 @@ def render_voter(): with st.form("vote", clear_on_submit=False): st.divider() picks = {} - for col, label in CATEGORIES: + for col, label, _ in CATEGORIES: picks[col] = st.radio( label, candidates, @@ -128,7 +128,7 @@ def render_voter(): submitted = st.form_submit_button("μ μΆ") if submitted: - if any(picks.get(col) is None for col, _ in CATEGORIES): + if any(picks.get(col) is None for col, _, _ in CATEGORIES): st.error("3λΆμΌ λͺ¨λ μ ννμΈμ.") return @@ -208,7 +208,7 @@ def render_admin(): public_lines = [] # μμμ λ°νμ© (νμ λΉκ³΅κ°) - for col, label in CATEGORIES: + for col, label, _ in CATEGORIES: rows = conn.execute( f"SELECT {col} AS team, COUNT(*) AS c FROM votes GROUP BY {col} ORDER BY c DESC, team ASC" ).fetchall() @@ -248,11 +248,111 @@ def render_admin(): conn.close() +def render_ceremony(): + """μμμ reveal νμ΄μ§. μ§νμκ° ν΄λ¦μΌλ‘ λ¨κ³λ³ 곡κ°.""" + token = st.query_params.get("token", "") + if token != ADMIN_TOKEN: + st.error("κΆν μμ. ?mode=ceremony&token=... νμ νμ.") + return + + titles = get_titles() + conn = get_conn() + + results = [] + for col, label, prize in CATEGORIES: + rows = conn.execute( + f"SELECT {col} AS team, COUNT(*) AS c FROM votes " + f"GROUP BY {col} ORDER BY c DESC, team ASC" + ).fetchall() + if rows: + winner, votes = rows[0] + runner = rows[1][1] if len(rows) > 1 else 0 + results.append((label, prize, winner, votes, votes - runner)) + conn.close() + + if "ceremony_step" not in st.session_state: + st.session_state.ceremony_step = 0 + if "ceremony_revealed" not in st.session_state: + st.session_state.ceremony_revealed = False + + st.markdown( + """ + + """, + unsafe_allow_html=True, + ) + + step = st.session_state.ceremony_step + + if step == 0: + st.markdown('