Skip to content

Commit

Permalink
clean up comments
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenson committed Dec 5, 2024
1 parent 7dda857 commit 188c4f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ export const AllCommentsTabContainer: FunctionComponent<Props> = ({
const commentSeenEnabled = useCommentSeenEnabled();
// calling loadMore will query GraphQL for 10 more comments
// (at the time of this writing, pagination queries are quite slow
// and values higher than 10 sometimes take as long as 10 seconds)
// and values higher than 10 sometimes take as long as 10 seconds),
// depending on how many comment replies must be recursively fetched
const [loadMore, isLoadingMore] = useLoadMore(relay, 10);
const beginLoadMoreEvent = useViewerNetworkEvent(LoadMoreAllCommentsEvent);
const beginViewNewCommentsEvent = useViewerNetworkEvent(
Expand Down
13 changes: 3 additions & 10 deletions server/src/core/server/graph/loaders/Comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,8 @@ export default (ctx: GraphContext) => ({
const isArchived = !!(story.isArchived || story.isArchiving);
const cacheAvailable = await ctx.cache.available(ctx.tenant.id);

// the following code

// regardless of cacheAvailable, we want to paginate the first call to prevent loading all comments at once
// subsequent calls (for more is 15 comments) should retrieve from cache if the totalComments are fewer than 500
// and should paginate via mongo if the totalComments are greater than 500

// if the story is archived or has a relatively large number of comments,
// comments will be paginated via queries to Mongo

// Regardless of cacheAvailable (true when DATA_CACHE is enabled),
// we want to conditionally paginate the first call to prevent loading too many comments at once.
if (
!cacheAvailable ||
isRatingsAndReviews(ctx.tenant, story) ||
Expand Down Expand Up @@ -510,7 +503,7 @@ export default (ctx: GraphContext) => ({
ctx.tenant.id,
comment,
{
first: 9999, // seems like lowering this doesn't help reduce Redis operations
first: 9999,
orderBy: defaultTo(orderBy, GQLCOMMENT_SORT.CREATED_AT_ASC),
},
story.isArchived
Expand Down

0 comments on commit 188c4f0

Please sign in to comment.