Skip to content

Commit

Permalink
fix(comments): return empty page if no entities found
Browse files Browse the repository at this point in the history
  • Loading branch information
undrcrxwn committed Mar 23, 2024
1 parent e639b72 commit a4d7da3
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CASE WHEN COUNT(reply) > 0 THEN COLLECT(DISTINCT {
}
""",
new { id = id.ToString() });

if (await data.PeekAsync() is null)
throw new NotFoundException();

Expand Down Expand Up @@ -104,7 +104,13 @@ OPTIONAL MATCH (deepReplyAuthor:Author)<-[:AUTHORED_BY]-(deepReply:Comment)-[:RE
});

if (await data.PeekAsync() is null)
throw new NotFoundException();
{
return new Page<CommentDto>
{
TotalCount = 0,
Items = Enumerable.Empty<CommentDto>()
};
}

var record = await data.SingleAsync();
return record[0].Adapt<Page<CommentDto>>();
Expand Down Expand Up @@ -199,6 +205,15 @@ CASE WHEN COUNT(reply) > 0 THEN COLLECT(DISTINCT {
count
});

if (await data.PeekAsync() is null)
{
return new Page<CommentDto>
{
TotalCount = 0,
Items = Enumerable.Empty<CommentDto>()
};
}

var record = await data.SingleAsync();
return record[0].Adapt<Page<CommentDto>>();
});
Expand Down

0 comments on commit a4d7da3

Please sign in to comment.