mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-07 12:28:39 +00:00
Fix rating ternary syntax
This commit is contained in:
parent
300613032d
commit
33f1d3fa82
1 changed files with 30 additions and 17 deletions
|
@ -110,41 +110,53 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int Plays { get => this.PlaysLBP1 + this.PlaysLBP2 + this.PlaysLBP3; }
|
public int Plays {
|
||||||
|
get => this.PlaysLBP1 + this.PlaysLBP2 + this.PlaysLBP3;
|
||||||
|
}
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int PlaysUnique { get => this.PlaysLBP1Unique + this.PlaysLBP2Unique + this.PlaysLBP3Unique; }
|
public int PlaysUnique {
|
||||||
|
get => this.PlaysLBP1Unique + this.PlaysLBP2Unique + this.PlaysLBP3Unique;
|
||||||
|
}
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public int PlaysComplete { get => this.PlaysLBP1Complete + this.PlaysLBP2Complete + this.PlaysLBP3Complete; }
|
public int PlaysComplete {
|
||||||
|
get => this.PlaysLBP1Complete + this.PlaysLBP2Complete + this.PlaysLBP3Complete;
|
||||||
|
}
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP1 { get; set; }
|
public int PlaysLBP1 { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP1Complete { get; set; }
|
public int PlaysLBP1Complete { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP1Unique { get; set; }
|
public int PlaysLBP1Unique { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP2 { get; set; }
|
public int PlaysLBP2 { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP2Complete { get; set; }
|
public int PlaysLBP2Complete { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP2Unique { get; set; }
|
public int PlaysLBP2Unique { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP3 { get; set; }
|
public int PlaysLBP3 { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP3Complete { get; set; }
|
public int PlaysLBP3Complete { get; set; }
|
||||||
|
|
||||||
[XmlIgnore]
|
[XmlIgnore]
|
||||||
public int PlaysLBP3Unique { get; set; }
|
public int PlaysLBP3Unique { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[XmlElement("thumbsup")]
|
[XmlElement("thumbsup")]
|
||||||
public int Thumbsup
|
public int Thumbsup {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
|
||||||
return database.RatedLevels.Count(r => r.SlotId == this.SlotId && r.Rating == 1);
|
return database.RatedLevels.Count(r => r.SlotId == this.SlotId && r.Rating == 1);
|
||||||
|
@ -153,10 +165,8 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[XmlElement("thumbsdown")]
|
[XmlElement("thumbsdown")]
|
||||||
public int Thumbsdown
|
public int Thumbsdown {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
|
||||||
return database.RatedLevels.Count(r => r.SlotId == this.SlotId && r.Rating == -1);
|
return database.RatedLevels.Count(r => r.SlotId == this.SlotId && r.Rating == -1);
|
||||||
|
@ -165,13 +175,16 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[XmlElement("averageRating")]
|
[XmlElement("averageRating")]
|
||||||
public double RatingLBP1 { get {
|
public double RatingLBP1 {
|
||||||
|
get {
|
||||||
using Database database = new();
|
using Database database = new();
|
||||||
|
|
||||||
IQueryable<RatedLevel> ratedLevels = database.RatedLevels.Where(r => r.SlotId == this.SlotId && r.RatingLBP1 > 0);
|
IQueryable<RatedLevel> ratedLevels = database.RatedLevels.Where(r => r.SlotId == this.SlotId && r.RatingLBP1 > 0);
|
||||||
if (!ratedLevels.Any()) return 3.0;
|
if (!ratedLevels.Any()) return 3.0;
|
||||||
|
|
||||||
return Enumerable.Average(ratedLevels, r => r.RatingLBP1); ;
|
return Enumerable.Average(ratedLevels, r => r.RatingLBP1);
|
||||||
|
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,10 +231,10 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
|
||||||
LbpSerializer.StringElement("thumbsup", this.Thumbsup) +
|
LbpSerializer.StringElement("thumbsup", this.Thumbsup) +
|
||||||
LbpSerializer.StringElement("thumbsdown", this.Thumbsdown) +
|
LbpSerializer.StringElement("thumbsdown", this.Thumbsdown) +
|
||||||
LbpSerializer.StringElement("averageRating", this.RatingLBP1) +
|
LbpSerializer.StringElement("averageRating", this.RatingLBP1) +
|
||||||
yourRating != null ? LbpSerializer.StringElement("yourRating", yourRating) : "" +
|
(yourRating != null ? LbpSerializer.StringElement("yourRating", yourRating) : "") +
|
||||||
yourDPadRating != null ? LbpSerializer.StringElement("yourDPadRating", yourDPadRating) : "" +
|
(yourDPadRating != null ? LbpSerializer.StringElement("yourDPadRating", yourDPadRating) : "") +
|
||||||
yourLBP1PlayCount != null ? LbpSerializer.StringElement("yourLBP1PlayCount", yourLBP1PlayCount) : "" +
|
(yourLBP1PlayCount != null ? LbpSerializer.StringElement("yourLBP1PlayCount", yourLBP1PlayCount) : "") +
|
||||||
yourLBP2PlayCount != null ? LbpSerializer.StringElement("yourLBP2PlayCount", yourLBP2PlayCount) : "";
|
(yourLBP2PlayCount != null ? LbpSerializer.StringElement("yourLBP2PlayCount", yourLBP2PlayCount) : "");
|
||||||
|
|
||||||
return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user");
|
return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue