Skip to content

Implement Playlist Statistics - #904

Merged
jvyden merged 3 commits into
LittleBigRefresh:mainfrom
Toastbrot236:playlist-statistics
Jul 30, 2025
Merged

Implement Playlist Statistics#904
jvyden merged 3 commits into
LittleBigRefresh:mainfrom
Toastbrot236:playlist-statistics

Conversation

@Toastbrot236

Copy link
Copy Markdown
Contributor

Adds playlist statistics, which work similarly to level and user statistics. Also slightly optimizes some playlist database methods and groups a few of them together to hopefully make them easier to follow.

@jvyden jvyden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the statistics system, it's important to keep track of the versioning as it's how Refresh knows when to update objects. Without bumping them with schema changes they will be out of date and will never catch up unless marked dirty.

I think I implemented it so that Refresh serves old data while a worker updates everything in the background.

{
[Required, Key] public int PlaylistId { get; set; }
public DateTimeOffset? RecalculateAt { get; set; } = null;
public int Version { get; set; } = GameDatabaseContext.LevelStatisticsVersion;

@jvyden jvyden Jul 29, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use the new PlaylistStatisticsVersion

}

#region Levels
internal const int LevelStatisticsVersion = 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be bumped to 3 so game server knows to upgrade the statistics. Same with UserStatisticsVersion, since we also modify that table.

@Toastbrot236

Copy link
Copy Markdown
Contributor Author

I just noticed that statistics for deleted levels/users don't get deleted and stay in the database. Is that intentional?

@jvyden

jvyden commented Jul 30, 2025

Copy link
Copy Markdown
Member

Very unexpected. Are they not being cascade deleted?

@jvyden
jvyden merged commit d541d6f into LittleBigRefresh:main Jul 30, 2025
3 checks passed
@Toastbrot236

Copy link
Copy Markdown
Contributor Author

Doesn't seem like it. They don't have .OnDelete(DeleteBehavior.Cascade) in GameDatabaseContextModelSnapshot and when I tested the version bump just now, my GameLevelStatistics table had one row which was still on version 2, which was referencing a deleted level.

@jvyden

jvyden commented Jul 30, 2025

Copy link
Copy Markdown
Member

I'll make an issue to track this.

@jvyden

jvyden commented Jul 30, 2025

Copy link
Copy Markdown
Member

#906

@Toastbrot236
Toastbrot236 deleted the playlist-statistics branch July 30, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants