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

list playground submissions on game pages #1940

Merged
merged 2 commits into from
Aug 11, 2024
Merged

list playground submissions on game pages #1940

merged 2 commits into from
Aug 11, 2024

Conversation

vadosnaprimer
Copy link
Collaborator

@vadosnaprimer vadosnaprimer commented Aug 11, 2024

Meant to close #1239

The query is bad but I failed to understand adelikat's explanations on how to improve it. Select() is absolute black magic for me, and I barely ever touched db manip.

The tabs need to be sorted too, but I thought it'd be bad to sort them in the 2 foreach places, and they should be sorted on the cs side, but it crashes if I add .OrderBy(g => g.Name.Length) to my query.

Whenever we have individual PG entries we may change the listed links to point to them instead, but this should be good for now.

@Masterjun3
Copy link
Collaborator

Here's a query that does both sortings for you (Goals by Name Length, and inside each goal by ID descending):

PlaygroundGoals = g.Submissions
	.Where(s => s.Status == SubmissionStatus.Playground)
	.GroupBy(s => s.GameGoal)
	.OrderBy(gg => gg.Key!.DisplayName.Length)
	.Select(gg => new GoalEntry(
		gg.Key!.Id,
		gg.Key!.DisplayName,
		gg.OrderByDescending(ggs => ggs.Id)
			.Select(ggs => new SubmissionEntry(ggs.Id, ggs.Title))
			.ToList()))
	.ToList(),

@adelikat adelikat merged commit e093c9b into main Aug 11, 2024
1 check passed
@adelikat adelikat deleted the playground_listing branch August 11, 2024 19:25
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.

Playground: List playground movies for associated game on game pages
3 participants