diff options
Diffstat (limited to 'Backend')
| -rw-r--r-- | Backend/Api/Api/Models/User.cs | 1 | ||||
| -rw-r--r-- | Backend/Api/Api/Services/PostService.cs | 3 | 
2 files changed, 4 insertions, 0 deletions
| diff --git a/Backend/Api/Api/Models/User.cs b/Backend/Api/Api/Models/User.cs index 52d0f24..620c9c8 100644 --- a/Backend/Api/Api/Models/User.cs +++ b/Backend/Api/Api/Models/User.cs @@ -82,6 +82,7 @@ namespace Api.Models          public int numberOfRatingsOnPosts { get; set; }          public double averagePostRatingOnPosts {get; set; }          public List<MonthlyViews> monthlyViews { get; set; } +        public int numberOfFavouritePosts { get; set; }      }      public class MonthlyViews diff --git a/Backend/Api/Api/Services/PostService.cs b/Backend/Api/Api/Services/PostService.cs index 0799f10..16ebbb7 100644 --- a/Backend/Api/Api/Services/PostService.cs +++ b/Backend/Api/Api/Services/PostService.cs @@ -672,6 +672,7 @@ namespace Api.Services              stats.numberOfPosts = 0;              stats.totalViews = 0;              stats.monthlyViews = new List<MonthlyViews>(); +            stats.numberOfFavouritePosts = 0;              if(posts != null) @@ -691,6 +692,8 @@ namespace Api.Services                      stats.totalViews += post.views;                      stats.numberOfRatingsOnPosts += post.ratingscount;                      stats.numberOfPosts++; +                    if(post.favourites!=null) +                        stats.numberOfFavouritePosts+=post.favourites.Count;                      ratingsum += post.ratings * post.ratingscount;                  }                  if(stats.numberOfRatingsOnPosts > 0) //don't forget to check div by 0 jesus | 
