Skip to content

Commit

Permalink
Still trying to fix freeze issue
Browse files Browse the repository at this point in the history
  • Loading branch information
richardr1126 committed Dec 6, 2024
1 parent 76c95e5 commit 93044bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: gunicorn web.app:app --bind 0.0.0.0:8000
web: gunicorn web.app:app --bind 0.0.0.0:8000 --workers 2
firehose: python start_stream.py
11 changes: 6 additions & 5 deletions web/algos/chrono_trending.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def build_cursor_condition(cursor_value: Optional[str]):

# Apply offset for trending_posts
trending_posts = list(trending_posts_query.offset(trending_posts_offset).limit(limit))
logger.info(f"Fetched {len(trending_posts)} trending posts with >={INTERACTIONS_THRESHOLD} interactions starting at offset {trending_posts_offset}")
#logger.info(f"Fetched {len(trending_posts)} trending posts with >={INTERACTIONS_THRESHOLD} interactions starting at offset {trending_posts_offset}")

trending_cids = [post.cid for post in trending_posts]

Expand All @@ -132,7 +132,7 @@ def build_cursor_condition(cursor_value: Optional[str]):
}

main_posts = list(main_posts_query.limit(limit)) # Fetch up to 'limit' main posts
logger.debug(f"Fetched {len(main_posts)} main posts excluding trending posts")
#logger.debug(f"Fetched {len(main_posts)} main posts excluding trending posts")

# Fetch my_posts excluding trending_posts
my_posts_query = (
Expand All @@ -152,7 +152,7 @@ def build_cursor_condition(cursor_value: Optional[str]):
my_posts_query = my_posts_query.where(Post.cid.not_in(trending_cids))

my_posts = list(my_posts_query.limit(limit)) # Fetch up to 'limit' my posts
logger.debug(f"Fetched {len(my_posts)} my posts excluding trending posts")
#logger.debug(f"Fetched {len(my_posts)} my posts excluding trending posts")

# Initialize iterators
my_posts_iter = iter(my_posts)
Expand Down Expand Up @@ -194,7 +194,7 @@ def build_cursor_condition(cursor_value: Optional[str]):
last_fetched[category] = post

if category == 'trending_posts': # Track the number of trending_posts fetched
logger.info(f"Added trending post | {post.interactions} | {post.indexed_at}")
#logger.info(f"Added trending post | {post.interactions} | {post.indexed_at}")
trending_count += 1

if len(combined_posts) >= limit:
Expand All @@ -220,7 +220,7 @@ def build_cursor_condition(cursor_value: Optional[str]):
logger.debug("No more main_posts to add during final filling")
break

logger.debug(f"Combined posts count after interleaving: {len(combined_posts)}")
#logger.debug(f"Combined posts count after interleaving: {len(combined_posts)}")

# Trim the list to the desired limit
combined_posts = combined_posts[:limit]
Expand All @@ -236,6 +236,7 @@ def build_cursor_condition(cursor_value: Optional[str]):
break

logger.info(f"Total unique posts in feed after deduplication: {len(unique_posts)}")
logger.info(f"Total trending posts in served: {trending_count}")

# Build the feed
feed = [{'post': post.uri} for post in unique_posts]
Expand Down

0 comments on commit 93044bf

Please sign in to comment.