Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/cloud-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ name: Cloud Run Continuous Deployment
on:
push:
# TODO: change 'none' to 'main' to enable the workflow to run
branches: 'main'
branches: 'none'
release:
types: [published]

env:
# TODO: Paste output from setup.sh below.
PROJECT_ID: 'daniel-reyes-uprm'
SERVICE_NAME: 'study-group-finder'
SERVICE_REGION: 'us-central1'
SERVICE_ACCOUNT: '828411740843-compute@developer.gserviceaccount.com'
WORKLOAD_IDENTITY_PROVIDER: 'projects/828411740843/locations/global/workloadIdentityPools/github-provider/providers/github-project-repo'
PROJECT_ID: ''
SERVICE_NAME: ''
SERVICE_REGION: ''
SERVICE_ACCOUNT: ''
WORKLOAD_IDENTITY_PROVIDER: ''

jobs:
py-checks:
Expand Down
14 changes: 14 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#############################################################################

import streamlit as st
from modules import display_user_profile, display_my_custom_component, display_post, display_genai_advice, display_recent_workouts
from modules import display_my_custom_component, study_group_card, navigation_bar, display_explore_page, display_genai_advice, display_activity_summary, display_recent_workouts
from data_fetcher import get_user_posts, get_genai_advice, get_user_profile, get_user_sensor_data, get_user_workouts

Expand Down Expand Up @@ -33,6 +34,19 @@ def display_app_page():



profile = {
"first_name": "Jane", "last_name": "Doe",
"major": "Computer Science", "year": "Junior Year",
"university": "Stanford University", "email": "jane.doe@stanford.edu",
"about_me": "Passionate about algorithms and AI...",
"focus_subjects": ["Data Structures", "Machine Learning"],
"groups_joined": 4, "study_hours": 127, "day_streak": 12,
"weekly_availability": [
{"day": "Mon", "slots": ["9-11 AM", "2-4 PM"]},
{"day": "Tue", "slots": ["1-3 PM"]},
],
}
display_user_profile(profile)

# This is the starting point for your app. You do not need to change these lines
if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions manual-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### VARIABLES TO CHANGE - START
PROJECT_ID=daniel-reyes-uprm
SERVICE_NAME=study-group-finder
PROJECT_ID=
SERVICE_NAME=
### VARIABLES TO CHANGE - END

# ----------- Manual Deployment ------------ #
Expand Down
114 changes: 84 additions & 30 deletions modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,6 @@
from internals import create_component
import streamlit as st

# CSS style for modules
st.markdown("""
<style>
.study-card {
border-radius: 18px;
padding: 20px;
background-color: #1e1e1e;
border: 1px solid #333;
margin-bottom: 20px;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.subject-tag {
display: inline-block;
padding: 4px 10px;
border-radius: 12px;
background-color: #2d2d2d;
font-size: 0.8rem;
margin-bottom: 8px;
}
.location {
color: #ff4b4b;
font-weight: 500;
}
</style>
""", unsafe_allow_html=True) # Written by Chat GPT


# This one has been written for you as an example. You may change it as wanted.
def display_my_custom_component(value):
"""Displays a 'my custom component' which showcases an example of how custom
Expand Down Expand Up @@ -163,9 +136,90 @@ def display_explore_page(group_list):



def display_activity_summary(workouts_list):
"""Write a good docstring here."""
pass
def display_user_profile(profile):
"""
Render the complete user profile page.

Args
profile : dict – All profile data for the user. Expected keys:
'first_name' : str
'last_name' : str
'major' : str
'year' : str (e.g. "Junior Year")
'university' : str
'email' : str
'about_me' : str
'focus_subjects' : list[str]
'groups_joined' : int
'study_hours' : int
'day_streak' : int
'weekly_availability' : list[dict] with keys 'day' and 'slots' (list[str])

Example
profile = {
"first_name": "Jane", "last_name": "Doe",
"major": "Computer Science", "year": "Junior Year",
"university": "Stanford University", "email": "jane.doe@stanford.edu",
"about_me": "Passionate about algorithms and AI...",
"focus_subjects": ["Data Structures", "Machine Learning"],
"groups_joined": 4, "study_hours": 127, "day_streak": 12,
"weekly_availability": [
{"day": "Mon", "slots": ["9-11 AM", "2-4 PM"]},
{"day": "Tue", "slots": ["1-3 PM"]},
],
}
display_user_profile(profile)
"""
if not profile:
st.warning("No profile data available.")
return

# ── Header ────────────────────────────────────────────────────────────────
initials = (profile["first_name"][0] + profile["last_name"][0]).upper()
col_avatar, col_info, col_btns = st.columns([1, 5, 2])

with col_avatar:
st.markdown(f"## {initials}")

with col_info:
st.subheader(f"{profile['first_name']} {profile['last_name']}")
st.caption(f"{profile['major']} · {profile['year']}")
st.write(f"🏛 {profile['university']} ✉ {profile['email']}")

with col_btns:
st.button("Edit Profile", use_container_width=True)
st.button("Share Profile", use_container_width=True)

st.divider()

# ── About Me ──────────────────────────────────────────────────────────────
st.markdown("**ABOUT ME**")
st.write(profile["about_me"])

st.markdown("**FOCUS SUBJECTS**")
st.write(" ".join([f"`{s}`" for s in profile["focus_subjects"]]))

st.divider()

# ── Stats ─────────────────────────────────────────────────────────────────
col1, col2, col3 = st.columns(3)
col1.metric("Groups Joined", profile["groups_joined"])
col2.metric("Study Hours", profile["study_hours"])
col3.metric("Day Streak", profile["day_streak"])

st.divider()

# ── Weekly Availability ───────────────────────────────────────────────────
avail_col, btn_col = st.columns([4, 1])
avail_col.markdown("**Weekly Availability**")
btn_col.button("Update Schedule", use_container_width=True)

cols = st.columns(len(profile["weekly_availability"]))
for col, day_data in zip(cols, profile["weekly_availability"]):
with col:
st.markdown(f"**{day_data['day']}**")
for slot in day_data["slots"]:
st.caption(slot)


def display_recent_workouts(workouts_list):
Expand Down
44 changes: 43 additions & 1 deletion modules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,53 @@
from unittest.mock import MagicMock, patch
import streamlit as st
from streamlit.testing.v1 import AppTest
from modules import display_explore_page, navigation_bar, study_group_card # display_activity_summary, display_genai_advice, display_recent_workouts
from modules import display_explore_page, navigation_bar, study_group_card, display_post, display_user_profile, display_genai_advice, display_recent_workouts

# Write your tests below
APP_FILE = "app.py"


class TestDisplayUserProfile(unittest.TestCase):

def test_profile_renders_without_exception(self):
"""Test that the profile page loads cleanly with no errors."""
at = AppTest.from_file(APP_FILE).run()

assert not at.exception

def test_full_name_displayed(self):
"""Test that the user's full name appears as a subheader."""
at = AppTest.from_file(APP_FILE).run()

subheader_values = [s.value for s in at.subheader]
assert any("Jane Doe" in v for v in subheader_values)

def test_stats_display_correct_values(self):
"""Test that all three stat metrics show the correct values."""
at = AppTest.from_file(APP_FILE).run()

metric_labels = [m.label for m in at.metric]
metric_values = [m.value for m in at.metric]
assert metric_values[metric_labels.index("Groups Joined")] == "4"
assert metric_values[metric_labels.index("Study Hours")] == "127"
assert metric_values[metric_labels.index("Day Streak")] == "12"

def test_availability_slots_displayed(self):
"""Test that time slot captions are rendered in the availability section."""
at = AppTest.from_file(APP_FILE).run()

caption_values = [c.value for c in at.caption]
assert any("9-11 AM" in v for v in caption_values)
assert any("1-3 PM" in v for v in caption_values)

def test_focus_subjects_displayed(self):
"""Test that focus subjects appear on the page."""
at = AppTest.from_file(APP_FILE).run()

all_text = " ".join([str(m.value) for m in at.markdown])
assert "Data Structures" in all_text
assert "Machine Learning" in all_text

class TestDisplayExplorePage(unittest.TestCase):
"""Tests the study group app using Streamlit AppTest."""

Expand Down
10 changes: 5 additions & 5 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
### VARIABLES TO CHANGE - START
PROJECT_ID=daniel-reyes-uprm
PROJECT_NUMBER=828411740843
SERVICE_NAME=study-group-finder
GITHUB_ORG=CodePath-Tech-Exchange-CTEx
GITHUB_REPO=code-and-conquer
PROJECT_ID=
PROJECT_NUMBER=
SERVICE_NAME=
GITHUB_ORG=
GITHUB_REPO=
### VARIABLES TO CHANGE - END

# ----------- Set Up GCP Project ----------- #
Expand Down
Loading