Skip to content

Commit

Permalink
chore: multiple hosting count
Browse files Browse the repository at this point in the history
  • Loading branch information
ychung-mot committed Nov 21, 2024
1 parent 1f94475 commit 3d0aa93
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion server/StrDss.Data/Repositories/RentalListingRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,26 @@ public async Task<int> GetGroupedRentalListingsCount(string? all, string? addres

return count;
}
//public async Task<int> CountHostListingsAsync(string hostName)
//{
// var query = _dbSet.AsNoTracking();

// if (_currentUser.OrganizationType == OrganizationTypes.LG)
// {
// query = query.Where(x => x.ManagingOrganizationId == _currentUser.OrganizationId);
// }

// return await query
// .Where(x => x.EffectiveHostNm == hostName)
// .GroupBy(x => new { x.EffectiveBusinessLicenceNo, x.EffectiveHostNm, x.MatchAddressTxt })
// .Select(g => new RentalListingGroupDto
// {
// EffectiveBusinessLicenceNo = g.Key.EffectiveBusinessLicenceNo,
// EffectiveHostNm = g.Key.EffectiveHostNm,
// MatchAddressTxt = g.Key.MatchAddressTxt
// })
// .CountAsync();
//}
public async Task<int> CountHostListingsAsync(string hostName)
{
var query = _dbSet.AsNoTracking();
Expand All @@ -170,7 +190,11 @@ public async Task<int> CountHostListingsAsync(string hostName)
query = query.Where(x => x.ManagingOrganizationId == _currentUser.OrganizationId);
}

return await query.CountAsync(x => x.EffectiveHostNm == hostName);
return await query
.Where(x => x.EffectiveHostNm == hostName)
.Select(x => new { x.EffectiveBusinessLicenceNo, x.EffectiveHostNm, x.MatchAddressTxt })
.Distinct()
.CountAsync();
}

private static void ApplyFilters(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
Expand Down

0 comments on commit 3d0aa93

Please sign in to comment.