Skip to content

Commit

Permalink
Revert "DB leaderboards (#66)" (#67)
Browse files Browse the repository at this point in the history
This reverts commit a965fbf.
  • Loading branch information
Simyon264 authored Nov 11, 2024
1 parent a965fbf commit bce888c
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 1,177 deletions.

This file was deleted.

70 changes: 0 additions & 70 deletions ReplayBrowser/Data/Migrations/20241111013501_DbLeaderboards.cs

This file was deleted.

68 changes: 0 additions & 68 deletions ReplayBrowser/Data/Migrations/ReplayDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,63 +301,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("JobDepartments");
});

modelBuilder.Entity("ReplayBrowser.Data.Models.LeaderboardDefinition", b =>
{
b.Property<string>("Name")
.HasColumnType("text");

b.Property<string>("ExtraInfo")
.HasColumnType("text");

b.Property<string>("NameColumn")
.IsRequired()
.HasColumnType("text");

b.Property<string>("TrackedData")
.IsRequired()
.HasColumnType("text");

b.HasKey("Name");

b.ToTable("LeaderboardDefinitions");
});

modelBuilder.Entity("ReplayBrowser.Data.Models.LeaderboardPosition", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");

NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));

b.Property<int>("Count")
.HasColumnType("integer");

b.Property<string>("LeaderboardDefinitionName")
.IsRequired()
.HasColumnType("text");

b.Property<Guid?>("PlayerGuid")
.HasColumnType("uuid");

b.Property<int>("Position")
.HasColumnType("integer");

b.Property<List<string>>("Servers")
.IsRequired()
.HasColumnType("text[]");

b.Property<string>("Username")
.IsRequired()
.HasColumnType("text");

b.HasKey("Id");

b.HasIndex("LeaderboardDefinitionName");

b.ToTable("Leaderboards");
});

modelBuilder.Entity("ReplayBrowser.Data.Models.Notice", b =>
{
b.Property<int?>("Id")
Expand Down Expand Up @@ -642,17 +585,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasForeignKey("CollectedPlayerDataPlayerGuid");
});

modelBuilder.Entity("ReplayBrowser.Data.Models.LeaderboardPosition", b =>
{
b.HasOne("ReplayBrowser.Data.Models.LeaderboardDefinition", "LeaderboardDefinition")
.WithMany()
.HasForeignKey("LeaderboardDefinitionName")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("LeaderboardDefinition");
});

modelBuilder.Entity("ReplayBrowser.Data.Models.Player", b =>
{
b.HasOne("ReplayBrowser.Data.Models.JobDepartment", "EffectiveJob")
Expand Down
27 changes: 0 additions & 27 deletions ReplayBrowser/Data/Models/LeaderboardDefinition.cs

This file was deleted.

54 changes: 0 additions & 54 deletions ReplayBrowser/Data/Models/LeaderboardPosition.cs

This file was deleted.

3 changes: 0 additions & 3 deletions ReplayBrowser/Data/ReplayDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,4 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
public DbSet<ReplayParticipant> ReplayParticipants { get; set; }

public DbSet<ServerToken> ServerTokens { get; set; }

public DbSet<LeaderboardPosition> Leaderboards { get; set; }
public DbSet<LeaderboardDefinition> LeaderboardDefinitions { get; set; }
}
7 changes: 7 additions & 0 deletions ReplayBrowser/Models/LeaderboardData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

namespace ReplayBrowser.Models;

public class LeaderboardData
{
public bool IsCache { get; set; } = false;

public List<Leaderboard> Leaderboards { get; set; } = null!;
}

public class PlayerCount
{
public PlayerData? Player { get; set; }
Expand Down
24 changes: 4 additions & 20 deletions ReplayBrowser/Pages/Leaderboard.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@page "/leaderboard"
@using Humanizer
@using Microsoft.AspNetCore.Components.Authorization
@using ReplayBrowser.Models
@using ReplayBrowser.Services
Expand All @@ -21,14 +20,6 @@

<PageTitle>Leaderboard</PageTitle>
<h4>Leaderboards</h4>
<em>Leaderboards update every 24 hours.</em>
@if(LeaderboardService.IsUpdating) {
<div class="alert alert-warning" role="alert">
<p>The leaderboards are currently updating. This may take a while. Please be patient.</p>
<em>Update started: @LeaderboardService.UpdateStarted.Humanize(utcDate: true). Current progress: @LeaderboardService.UpdateProgress / @LeaderboardService.UpdateTotal</em>
</div>
}

@if(RequestedPrivate)
{
<div class="alert alert-danger" role="alert">
Expand Down Expand Up @@ -114,14 +105,7 @@ else

<hr/>

@if(LeaderboardData.Length == 0)
{
<div class="alert alert-warning" role="alert">
<p>No data was found for the selected servers and time range. Data is probably still collected and calculated. Please try again later. This will take a long time.</p>
</div>
}

@foreach (var leaderboard in LeaderboardData)
@foreach (var leaderboard in LeaderboardData.Leaderboards)
{
<h4>@leaderboard.Name</h4>
if (leaderboard.ExtraInfo != null)
Expand Down Expand Up @@ -249,7 +233,7 @@ else

@code{
private bool IsLoading { get; set; } = true;
private Models.Leaderboard[]? LeaderboardData { get; set; } = null;
private LeaderboardData? LeaderboardData { get; set; } = null;
private bool RequestedPrivate { get; set; } = false;

protected override async Task OnInitializedAsync()
Expand Down Expand Up @@ -283,7 +267,7 @@ else
}
}

Models.Leaderboard[]? leaderboard = null;
LeaderboardData? leaderboard = null;
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
try
{
Expand All @@ -295,7 +279,7 @@ else
}

var selectedServersArray = selectedServers.Split(',');
leaderboard = await LeaderboardService.GetLeaderboards(timeRangeEnum, username, selectedServersArray, authState, entries);
leaderboard = await LeaderboardService.GetLeaderboard(timeRangeEnum, username, selectedServersArray, authState, entries);
}
catch (UnauthorizedAccessException)
{
Expand Down
Loading

0 comments on commit bce888c

Please sign in to comment.