diff options
author | Jelena Petrovic <jelenapetrovic.7119@gmail.com> | 2022-12-08 17:17:09 +0100 |
---|---|---|
committer | Jelena Petrovic <jelenapetrovic.7119@gmail.com> | 2022-12-08 17:17:09 +0100 |
commit | 3249bb44349919e587ec2c7e44b75c4e2e324d7f (patch) | |
tree | 3f469d14131fd9c078c146e2bb1725e43eccb00e /Backend | |
parent | 3fcabd8a0bf53bf6e55c9afd45aef76c7e2bf178 (diff) | |
parent | bb5e7d1282cccfdac13912b3222be85d0a209fc9 (diff) |
Merge branch 'develop' of http://gitlab.pmf.kg.ac.rs/BrzoDoLokacije2022/odyssey/brzodolokacije into develop
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 |