Add server-side ELO ratings
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
|
||||
namespace QuestionsApi.Models;
|
||||
|
||||
public class UserRating
|
||||
{
|
||||
[BsonId]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string? Id { get; set; }
|
||||
|
||||
public string UserId { get; set; } = "";
|
||||
public int OverallElo { get; set; } = 1000;
|
||||
public Dictionary<string, int> CategoryElos { get; set; } = [];
|
||||
public int RatedQuestionCount { get; set; }
|
||||
public DateTime UpdatedUtc { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public class QuestionRating
|
||||
{
|
||||
[BsonId]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string? Id { get; set; }
|
||||
|
||||
public string QuestionExternalId { get; set; } = "";
|
||||
public int Elo { get; set; } = 1000;
|
||||
public int AttemptCount { get; set; }
|
||||
public DateTime UpdatedUtc { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public class RatingChangeResponse
|
||||
{
|
||||
public bool Rated { get; set; }
|
||||
public string Category { get; set; } = "";
|
||||
public int UserOverallElo { get; set; }
|
||||
public int UserOverallDelta { get; set; }
|
||||
public int UserCategoryElo { get; set; }
|
||||
public int UserCategoryDelta { get; set; }
|
||||
public int QuestionElo { get; set; }
|
||||
public int QuestionEloDelta { get; set; }
|
||||
}
|
||||
|
||||
public class RatingProfileResponse
|
||||
{
|
||||
public int OverallElo { get; set; }
|
||||
public int RatedQuestionCount { get; set; }
|
||||
public Dictionary<string, int> CategoryElos { get; set; } = [];
|
||||
}
|
||||
Reference in New Issue
Block a user