From a68de970f162fc7537a4ac54ac78e3193b8c2576 Mon Sep 17 00:00:00 2001 From: Hipposgrumm Date: Mon, 27 Jan 2025 10:49:38 -0700 Subject: [PATCH] Pod (and other stuff) Rating: Complete Edition --- src/Controllers/Common/RatingController.cs | 38 +++++++++++++++------- src/Schema/RatingRankInfo.cs | 2 +- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/Controllers/Common/RatingController.cs b/src/Controllers/Common/RatingController.cs index 77f51eb..425a697 100644 --- a/src/Controllers/Common/RatingController.cs +++ b/src/Controllers/Common/RatingController.cs @@ -138,7 +138,7 @@ public class RatingController : Controller CategoryID = category, RatedEntityID = eID, RatedUserID = uID, - Rank = 0 // Start here, work way down. + Rank = 0 }; ctx.RatingRanks.Add(rank); } @@ -159,19 +159,20 @@ public class RatingController : Controller } if (eID != -1 || uID != null) { RatingRank[] ranks = ctx.RatingRanks - .Where(rr => rr.CategoryID == category) // Only rank by category. + .Where(rr => rr != rank && rr.CategoryID == category) // Only rank by category. .OrderBy(rr => rr.Rank) .ToArray(); bool resortOthers = false; + rank.Rank = 1; // Start here, work way down. for (int i=0;i categoryID == r.CategoryID && r.RatedEntityID == ratedEntityID && r.RatedUserID == null ); @@ -237,7 +241,7 @@ public class RatingController : Controller [Route("RatingWebService.asmx/GetTopRatedByCategoryID")] public RatingRankInfo[] GetRanks([FromForm] int categoryID, [FromForm] int numberOfRecord) { return ctx.RatingRanks - .Where(rr => categoryID == rr.CategoryID && rr.RatedUserID == null) + .Where(rr => categoryID == rr.CategoryID) .Take(numberOfRecord) .Select(rr => new RatingRankInfo(rr)) .ToArray(); @@ -247,15 +251,25 @@ public class RatingController : Controller [Produces("application/xml")] [Route("RatingWebService.asmx/GetTopRatedUserByCategoryID")] public IActionResult GetUserRanks([FromForm] int categoryID, [FromForm] int numberOfRecord) { - return Ok(new ArrayOfUserRatingRankInfo { + Console.WriteLine(new ArrayOfUserRatingRankInfo { UserRatingRankInfo = ctx.RatingRanks .Where(rr => rr.RatedUserID != null && (categoryID == rr.CategoryID - || (categoryID == 4 && rr.CategoryID == 5) // The party board searches for 4 but the pod rating is set by 5. + || (categoryID == 4 && rr.CategoryID == 5) // The party board searches for 4 but the pod rating is set in 5. )) .Take(numberOfRecord) .Select(rr => new UserRatingRankInfo { RankInfo = new RatingRankInfo(rr) }) .ToArray() }); + return Ok(new ArrayOfUserRatingRankInfo { + UserRatingRankInfo = ctx.RatingRanks + .Where(rr => rr.RatedUserID != null && (categoryID == rr.CategoryID + || (categoryID == 4 && rr.CategoryID == 5) // The party board searches for 4 but the pod rating is set in 5. + )) + .OrderBy(rr => rr.Rank) + .Take(numberOfRecord) + .Select(rr => new UserRatingRankInfo { RankInfo = new RatingRankInfo(rr), RatedUserID = new Guid(rr.RatedUserID) }) + .ToArray() + }); } [HttpPost] diff --git a/src/Schema/RatingRankInfo.cs b/src/Schema/RatingRankInfo.cs index fd576d7..f5e7cb1 100644 --- a/src/Schema/RatingRankInfo.cs +++ b/src/Schema/RatingRankInfo.cs @@ -11,7 +11,7 @@ public class RatingRankInfo { public RatingRankInfo(RatingRank rank) { Id = rank.Id; CategoryID = rank.CategoryID; - RatedEntityID = rank.RatedEntityID; + RatedEntityID = rank.RatedEntityID??0; Rank = rank.Rank; RatingAverage = rank.RatingAverage; TotalVotes = rank.TotalVotes;