Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "DB leaderboards" #67

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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
Loading