Skip to content

Commit 03d72b0

Browse files
committed
Social feed working, still need to add delete posts and find a way to hook workouts in history to a post
1 parent 4493370 commit 03d72b0

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

KonditionExpo/app/create-post.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,14 @@ export default function CreatePostScreen() {
276276
)}
277277
<View style={styles.previewStats}>
278278
<Text style={styles.previewStat}>
279-
🏃‍♂️ {formData.workout_type}
279+
<Text>🏃‍♂️ {formData.workout_type}</Text>
280280
</Text>
281281
<Text style={styles.previewStat}>
282-
⏱️ {formatDuration(formData.duration_minutes)}
282+
<Text>⏱️ {formatDuration(formData.duration_minutes)}</Text>
283283
</Text>
284284
{formData.calories_burned && (
285285
<Text style={styles.previewStat}>
286-
🔥 {formData.calories_burned} cal
286+
<Text>🔥 {formData.calories_burned} cal</Text>
287287
</Text>
288288
)}
289289
</View>

backend/app/crud/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
delete_workout_post,
1111
follow_user,
1212
get_feed_posts,
13+
get_personal_feed_posts,
14+
get_public_feed_posts,
15+
get_combined_feed_posts,
1316
get_follower_count,
1417
get_followers,
1518
get_following,
1619
get_following_count,
1720
get_user_workout_posts,
1821
get_workout_post,
1922
is_following,
23+
is_mutual_follow,
2024
search_users,
2125
unfollow_user,
2226
update_workout_post,
@@ -61,6 +65,10 @@
6165
"get_workout_post",
6266
"get_user_workout_posts",
6367
"get_feed_posts",
68+
"get_personal_feed_posts",
69+
"get_public_feed_posts",
70+
"get_combined_feed_posts",
71+
"is_mutual_follow",
6472
"update_workout_post",
6573
"delete_workout_post",
6674
]

backend/app/crud/social.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ def get_personal_feed_posts(
225225
Get workout posts from users that the specified user follows (personal feed).
226226
Includes privacy filtering: private posts only visible if mutual follow.
227227
"""
228+
# Early check: if no WorkoutPost records exist, return empty result immediately
229+
total_posts_check = session.exec(select(func.count()).select_from(WorkoutPost)).one()
230+
if total_posts_check == 0:
231+
return [], 0
232+
228233
# Get IDs of users that the current user follows
229234
following_statement = (
230235
select(UserFollow.followed_id)
@@ -235,16 +240,18 @@ def get_personal_feed_posts(
235240
# Include the user's own posts in the feed
236241
following_ids.append(user_id)
237242

243+
# If no one to follow (including self), return empty
244+
if not following_ids:
245+
return [], 0
246+
238247
# Build privacy filter conditions
239248
privacy_conditions = []
240249

241250
for followed_id in following_ids:
242251
if followed_id == user_id:
243252
# User's own posts - always visible
244253
privacy_conditions.append(
245-
and_(
246-
WorkoutPost.user_id == user_id
247-
)
254+
WorkoutPost.user_id == user_id
248255
)
249256
else:
250257
# Posts from followed users
@@ -297,6 +304,11 @@ def get_public_feed_posts(
297304
"""
298305
Get all public workout posts from all users (discovery feed).
299306
"""
307+
# Early check: if no WorkoutPost records exist, return empty result immediately
308+
total_posts_check = session.exec(select(func.count()).select_from(WorkoutPost)).one()
309+
if total_posts_check == 0:
310+
return [], 0
311+
300312
# Count all public posts
301313
count_statement = (
302314
select(func.count())

0 commit comments

Comments
 (0)