Add updatetime to rank entries

This commit is contained in:
2021-11-07 00:43:38 -04:00
parent 6f591af5ae
commit aa3a2cb4f4
6 changed files with 1160 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -9,12 +10,20 @@ namespace TOOHUCardAPI.DTO.RankData
{ {
[JsonProperty("rank_type")] [JsonProperty("rank_type")]
public string RankType { get; set; } public string RankType { get; set; }
[JsonProperty("steamid")]
public long SteamId { get; set; } public long SteamId { get; set; }
[JsonProperty("userid")]
public long UserId { get; set; } public long UserId { get; set; }
[JsonProperty("username")]
public string Username { get; set; } public string Username { get; set; }
[JsonProperty("version")]
public string Version { get; set; } public string Version { get; set; }
[JsonProperty("wave")]
public int Wave { get; set; } public int Wave { get; set; }
[JsonProperty("damage")]
public long Damage { get; set; } public long Damage { get; set; }
[JsonProperty("updatetime")]
public DateTime UpdateTime { get; set; }
[JsonIgnore] [JsonIgnore]
public Dictionary<string, string> Cards { get; set; } public Dictionary<string, string> Cards { get; set; }
} }
@@ -32,6 +41,7 @@ namespace TOOHUCardAPI.DTO.RankData
Version = rankEntry.Version, Version = rankEntry.Version,
Wave = rankEntry.Wave, Wave = rankEntry.Wave,
Damage = rankEntry.Damage, Damage = rankEntry.Damage,
UpdateTime = rankEntry.UpdateTime,
Cards = rankEntry.TowersUsed.Select(tower => KeyValuePair.Create(tower.TowerKey, tower.EncodedData)) Cards = rankEntry.TowersUsed.Select(tower => KeyValuePair.Create(tower.TowerKey, tower.EncodedData))
.ToDictionary(kv => kv.Key, kv => kv.Value) .ToDictionary(kv => kv.Key, kv => kv.Value)
}; };

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@@ -17,6 +18,7 @@ namespace TOOHUCardAPI.Data.Models
public string Version { get; set; } public string Version { get; set; }
public int Wave { get; set; } public int Wave { get; set; }
public long Damage { get; set; } public long Damage { get; set; }
public DateTime UpdateTime { get; set; }
public List<RankTowerEntry> TowersUsed { get; set; } public List<RankTowerEntry> TowersUsed { get; set; }
} }
} }

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -45,7 +46,8 @@ namespace TOOHUCardAPI.Data.Services
Version = entry.Version, Version = entry.Version,
Wave = entry.Wave, Wave = entry.Wave,
Damage = entry.Damage, Damage = entry.Damage,
TowersUsed = towersUsed TowersUsed = towersUsed,
UpdateTime = DateTime.Now
}; };
await _rankRepository.InsertRankEntry(toUpload); await _rankRepository.InsertRankEntry(toUpload);
_logger.LogInformation("Uploaded a rank entry for {SteamId}", entry.SteamId); _logger.LogInformation("Uploaded a rank entry for {SteamId}", entry.SteamId);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace TOOHUCardAPI.Migrations
{
public partial class updatetime : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "UpdateTime",
table: "RankEntries",
type: "timestamp without time zone",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "UpdateTime",
table: "RankEntries");
}
}
}

View File

@@ -956,6 +956,9 @@ namespace TOOHUCardAPI.Migrations
b.Property<int>("RankType") b.Property<int>("RankType")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<DateTime>("UpdateTime")
.HasColumnType("timestamp without time zone");
b.Property<long?>("UserSteamId") b.Property<long?>("UserSteamId")
.HasColumnType("bigint"); .HasColumnType("bigint");