mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00

Implements the rating system. Shipwreck Lagoon tracks theoretically work, but there's currently no way of testing them. There is a hack to make the ranked pods section of the blaster party board work. Don't know if that'll cause any issues (but I don't think so). SQLite database schema changes: ```sql CREATE TABLE "RatingRanks" ( "Id" INTEGER NOT NULL, "CategoryID" INTEGER NOT NULL, "RatedEntityID" INTEGER, "RatedUserID" TEXT, "Rank" INTEGER NOT NULL, "RatingAverage" REAL NOT NULL, "UpdateDate" TEXT NOT NULL, CONSTRAINT "PK_RatingRanks" PRIMARY KEY("Id" AUTOINCREMENT) ); CREATE TABLE "Ratings" ( "Id" INTEGER NOT NULL, "VikingId" INTEGER NOT NULL, "RankId" INTEGER NOT NULL, "Value" INTEGER NOT NULL, "Date" TEXT NOT NULL, CONSTRAINT "FK_Ratings_RatingRanks_RankId" FOREIGN KEY("RankId") REFERENCES "RatingRanks"("Id") ON DELETE CASCADE, CONSTRAINT "PK_Ratings" PRIMARY KEY("Id" AUTOINCREMENT), CONSTRAINT "FK_Ratings_Vikings_VikingId" FOREIGN KEY("VikingId") REFERENCES "Vikings"("Id") ON DELETE CASCADE ); ``` --------- Co-authored-by: Robert Paciorek <robert@opcode.eu.org>
41 lines
981 B
C#
41 lines
981 B
C#
using sodoff.Model;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace sodoff.Schema;
|
|
|
|
[XmlRoot(ElementName = "RatingRankInfo", Namespace = "")]
|
|
[Serializable]
|
|
public class RatingRankInfo {
|
|
|
|
public RatingRankInfo() {}
|
|
public RatingRankInfo(RatingRank rank) {
|
|
Id = rank.Id;
|
|
CategoryID = rank.CategoryID;
|
|
RatedEntityID = rank.RatedEntityID??0;
|
|
Rank = rank.Rank;
|
|
RatingAverage = rank.RatingAverage;
|
|
TotalVotes = rank.Ratings.Count;
|
|
UpdateDate = rank.UpdateDate;
|
|
}
|
|
|
|
[XmlElement(ElementName = "ID")]
|
|
public int Id;
|
|
|
|
[XmlElement(ElementName = "CID")]
|
|
public int CategoryID;
|
|
|
|
[XmlElement(ElementName = "EID")]
|
|
public int? RatedEntityID;
|
|
|
|
[XmlElement(ElementName = "R")]
|
|
public int Rank;
|
|
|
|
[XmlElement(ElementName = "RA")]
|
|
public float RatingAverage;
|
|
|
|
[XmlElement(ElementName = "TV")]
|
|
public int TotalVotes;
|
|
|
|
[XmlElement(ElementName = "UD")]
|
|
public DateTime UpdateDate;
|
|
} |