Made rating price ratio use more strict.
Reorganized modules_content.json.
This commit is contained in:
parent
e675962c35
commit
e07b234eb2
@ -7,12 +7,11 @@ namespace MultiShop.DataStructures
|
|||||||
{
|
{
|
||||||
public ProductListing Listing { get; private set; }
|
public ProductListing Listing { get; private set; }
|
||||||
public string ShopName { get; private set; }
|
public string ShopName { get; private set; }
|
||||||
public float RatingToPriceRatio {
|
public float? RatingToPriceRatio {
|
||||||
get {
|
get {
|
||||||
int reviewFactor = Listing.ReviewCount.HasValue ? Listing.ReviewCount.Value : 1;
|
int reviewFactor = Listing.ReviewCount.HasValue ? Listing.ReviewCount.Value : 1;
|
||||||
int purchaseFactor = Listing.PurchaseCount.HasValue ? Listing.PurchaseCount.Value : 1;
|
int purchaseFactor = Listing.PurchaseCount.HasValue ? Listing.PurchaseCount.Value : 1;
|
||||||
float ratingFactor = 1 + (Listing.Rating.HasValue ? Listing.Rating.Value : 0);
|
return (Listing.Rating * (reviewFactor > purchaseFactor ? reviewFactor : purchaseFactor))/(Listing.LowerPrice * Listing.UpperPrice);
|
||||||
return (ratingFactor * (reviewFactor > purchaseFactor ? reviewFactor : purchaseFactor))/(Listing.LowerPrice * Listing.UpperPrice);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ISet<ResultsProfile.Category> Tops { get; private set; } = new HashSet<ResultsProfile.Category>();
|
public ISet<ResultsProfile.Category> Tops { get; private set; } = new HashSet<ResultsProfile.Category>();
|
||||||
|
@ -11,8 +11,9 @@ namespace MultiShop.DataStructures
|
|||||||
switch (category)
|
switch (category)
|
||||||
{
|
{
|
||||||
case ResultsProfile.Category.RatingPriceRatio:
|
case ResultsProfile.Category.RatingPriceRatio:
|
||||||
float dealDiff = a.RatingToPriceRatio - b.RatingToPriceRatio;
|
float? dealDiff = a.RatingToPriceRatio - b.RatingToPriceRatio;
|
||||||
int dealCeil = (int)Math.Ceiling(Math.Abs(dealDiff));
|
if (!dealDiff.HasValue) return null;
|
||||||
|
int dealCeil = (int)Math.Ceiling(Math.Abs(dealDiff.Value));
|
||||||
return dealDiff < 0 ? -dealCeil : dealCeil;
|
return dealDiff < 0 ? -dealCeil : dealCeil;
|
||||||
case ResultsProfile.Category.Price:
|
case ResultsProfile.Category.Price:
|
||||||
float priceDiff = b.Listing.UpperPrice - a.Listing.UpperPrice;
|
float priceDiff = b.Listing.UpperPrice - a.Listing.UpperPrice;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
@page "/"
|
@page "/"
|
||||||
|
|
||||||
|
@* TODO: Add main page content.*@
|
||||||
<h1>Welcome to MultiShop!</h1>
|
<h1>Welcome to MultiShop!</h1>
|
@ -7,8 +7,7 @@
|
|||||||
@inject IConfiguration Configuration
|
@inject IConfiguration Configuration
|
||||||
@inject IJSRuntime js
|
@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="my-2">
|
||||||
<div class="input-group 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">
|
<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);
|
List<ProductListingInfo> sorted = new List<ProductListingInfo>(listings);
|
||||||
sorted.Sort((a, b) =>
|
sorted.Sort((a, b) =>
|
||||||
{
|
{
|
||||||
foreach (ResultsProfile.Category category in activeResultsProfile.Order)
|
foreach (ResultsProfile.Category category in activeResultsProfile.Order)
|
||||||
{
|
{
|
||||||
int? compareResult = category.CompareListings(a, b);
|
int? compareResult = category.CompareListings(a, b);
|
||||||
if (compareResult.HasValue && compareResult.Value != 0)
|
if (compareResult.HasValue && compareResult.Value != 0)
|
||||||
{
|
{
|
||||||
return -compareResult.Value;
|
return -compareResult.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
return sorted;
|
return sorted;
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[
|
[
|
||||||
"AliExpressShop",
|
|
||||||
"HtmlAgilityPack",
|
"HtmlAgilityPack",
|
||||||
|
"AliExpressShop",
|
||||||
"BanggoodShop"
|
"BanggoodShop"
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user