Made rating price ratio use more strict.

Reorganized modules_content.json.
This commit is contained in:
Harrison Deng 2021-05-18 19:34:32 -05:00
parent e675962c35
commit e07b234eb2
5 changed files with 18 additions and 18 deletions

View File

@ -7,12 +7,11 @@ namespace MultiShop.DataStructures
{
public ProductListing Listing { get; private set; }
public string ShopName { get; private set; }
public float RatingToPriceRatio {
public float? RatingToPriceRatio {
get {
int reviewFactor = Listing.ReviewCount.HasValue ? Listing.ReviewCount.Value : 1;
int purchaseFactor = Listing.PurchaseCount.HasValue ? Listing.PurchaseCount.Value : 1;
float ratingFactor = 1 + (Listing.Rating.HasValue ? Listing.Rating.Value : 0);
return (ratingFactor * (reviewFactor > purchaseFactor ? reviewFactor : purchaseFactor))/(Listing.LowerPrice * Listing.UpperPrice);
return (Listing.Rating * (reviewFactor > purchaseFactor ? reviewFactor : purchaseFactor))/(Listing.LowerPrice * Listing.UpperPrice);
}
}
public ISet<ResultsProfile.Category> Tops { get; private set; } = new HashSet<ResultsProfile.Category>();

View File

@ -11,8 +11,9 @@ namespace MultiShop.DataStructures
switch (category)
{
case ResultsProfile.Category.RatingPriceRatio:
float dealDiff = a.RatingToPriceRatio - b.RatingToPriceRatio;
int dealCeil = (int)Math.Ceiling(Math.Abs(dealDiff));
float? dealDiff = a.RatingToPriceRatio - b.RatingToPriceRatio;
if (!dealDiff.HasValue) return null;
int dealCeil = (int)Math.Ceiling(Math.Abs(dealDiff.Value));
return dealDiff < 0 ? -dealCeil : dealCeil;
case ResultsProfile.Category.Price:
float priceDiff = b.Listing.UpperPrice - a.Listing.UpperPrice;

View File

@ -1,3 +1,4 @@
@page "/"
@* TODO: Add main page content.*@
<h1>Welcome to MultiShop!</h1>

View File

@ -7,8 +7,7 @@
@inject IConfiguration Configuration
@inject IJSRuntime js
@* TODO: Add buttons for the order changing. Add main page. *@
@* TODO: Split C# code into a partial class. *@
<div class="my-2">
<div class="input-group my-2">
<input type="text" class="form-control" placeholder="What are you looking for?" aria-label="What are you looking for?" id="search-input" @bind="Query" @onkeyup="@(async (a) => {if (a.Code == "Enter" || a.Code == "NumpadEnter") await PerformSearch(Query);})" disabled="@searching">
@ -392,16 +391,16 @@
{
List<ProductListingInfo> sorted = new List<ProductListingInfo>(listings);
sorted.Sort((a, b) =>
{
foreach (ResultsProfile.Category category in activeResultsProfile.Order)
{
int? compareResult = category.CompareListings(a, b);
if (compareResult.HasValue && compareResult.Value != 0)
{
return -compareResult.Value;
}
}
return 0;
{
foreach (ResultsProfile.Category category in activeResultsProfile.Order)
{
int? compareResult = category.CompareListings(a, b);
if (compareResult.HasValue && compareResult.Value != 0)
{
return -compareResult.Value;
}
}
return 0;
});
return sorted;
});

View File

@ -1,5 +1,5 @@
[
"AliExpressShop",
"HtmlAgilityPack",
"AliExpressShop",
"BanggoodShop"
]