mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-14 10:04:55 +00:00
fixed how ratings are averaged
This commit is contained in:
parent
40aa399549
commit
1d02758d71
@ -28,6 +28,9 @@ public static class SellerProfileModelExtensions
|
||||
}
|
||||
public static DiscoverySellerModel ToDiscoveryModel(this UserSellerProfile sellerProfile)
|
||||
{
|
||||
var reviews = sellerProfile.SellerServices.SelectMany(x=>x.Reviews).Select(x=>x.ToDiscoveryModel());
|
||||
var reviewAverage = reviews.Average(x=>x.Rating);
|
||||
|
||||
return new DiscoverySellerModel()
|
||||
{
|
||||
Name = sellerProfile.User.DisplayName,
|
||||
@ -35,8 +38,8 @@ public static class SellerProfileModelExtensions
|
||||
SocialMediaLinks = sellerProfile.SocialMediaLinks,
|
||||
Biography = sellerProfile.Biography,
|
||||
PrepaymentRequired = sellerProfile.PrepaymentRequired,
|
||||
AverageRating = sellerProfile.SellerServices?.Average(x=>x.Reviews?.Average(y=>y.Rating)),
|
||||
ReviewCount = sellerProfile.SellerServices?.Sum(x=>x.Reviews.Count)
|
||||
AverageRating =reviewAverage,
|
||||
ReviewCount = reviews.Count()
|
||||
};
|
||||
}
|
||||
public static UserSellerProfile ToModel(this SellerProfileModel sellerProfile, UserSellerProfile existingSellerProfile)
|
||||
|
Loading…
x
Reference in New Issue
Block a user