Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ await WriteErrorAsync(context, StatusCodes.Status409Conflict,
}
catch (DomainException ex)
{
_logger.LogWarning(ex, "Domain exception: {DomainMessage}", ex.Message);
await WriteErrorAsync(context, StatusCodes.Status400BadRequest,
"BAD_REQUEST", MessageType.BusinessRule, ex.Message).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public async Task<Response<PagedResult<PublicTopicItemDto>>> Handle(

if (request.SortBy == TopicsSortBy.PostsCount)
{
var postCounts = await _db.Posts
.Where(p => p.Status == PostStatus.Published)
.GroupBy(p => p.TopicId)
.Select(g => new { TopicId = g.Key, Count = g.Count() })
var postCounts = await (
from p in _db.Posts
join c in _db.Communities on p.CommunityId equals c.Id
where p.Status == PostStatus.Published
&& c.IsActive
&& c.Visibility == CommunityVisibility.Public
group p by p.TopicId into g
select new { TopicId = g.Key, Count = g.Count() })
.ToListAsyncEither(ct)
.ConfigureAwait(false);

Expand Down Expand Up @@ -102,10 +106,15 @@ public async Task<Response<PagedResult<PublicTopicItemDto>>> Handle(

var pagedTopicMap = pagedTopics.ToDictionary(t => t.Id);

var pagedPostCounts = await _db.Posts
.Where(p => topicIds.Contains(p.TopicId) && p.Status == PostStatus.Published)
.GroupBy(p => p.TopicId)
.Select(g => new { TopicId = g.Key, Count = g.Count() })
var pagedPostCounts = await (
from p in _db.Posts
join c in _db.Communities on p.CommunityId equals c.Id
where topicIds.Contains(p.TopicId)
&& p.Status == PostStatus.Published
&& c.IsActive
&& c.Visibility == CommunityVisibility.Public
group p by p.TopicId into g
select new { TopicId = g.Key, Count = g.Count() })
.ToListAsyncEither(ct)
.ConfigureAwait(false);

Expand Down