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

Support role for puzzles #1134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tabascq
Copy link
Contributor

@tabascq tabascq commented Jan 5, 2025

Allows the designation of individual users in a support role for a puzzle.

A puzzle supporter would function basically as an author who does not appear in the credits, so the safest course is to choose that path of least resistance and implement it that way. This minimizes the possibility for bugs.

Also taking this opportunity to broaden the animal representation of the demo project.

Allows the designation of individual users in a support role for a puzzle.

A puzzle supporter would function basically as an author who does not appear in the credits, so the safest course is to choose that path of least resistance and implement it that way. This minimizes the possibility for bugs.

Also taking this opportunity to broaden the animal representation of the demo project.
@tabascq
Copy link
Contributor Author

tabascq commented Jan 5, 2025

Fixes #1096


if (!(await _context.PuzzleAuthors.Where(m => m.PuzzleID == puzzleId && m.AuthorID == NewSupportID).AnyAsync()))
{
_context.PuzzleAuthors.Add(new PuzzleAuthors() { PuzzleID = puzzleId, AuthorID = NewSupportID, SupportOnly = true });
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this will throw because of a duplicate key if the user is already an author on the puzzle (or vice versa if you're trying to promote support to author).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't throw because there's only one table for both - PuzzleAuthors. Since the query doesn't check the value of the SupportOnly field, the query covers both cases simultaneously.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, the only users who appear in the list are users in PotentialAuthorOrSupport, so casual use won't run into any weird scenarios unless you click twice or race another user.

@@ -55,7 +55,7 @@ public IActionResult OnGet()

for (int i = 1; ; i++)
{
string name = $"Watership Demo {i}";
string name = $"Animal Farm {i}";
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocking comment, but Animal Farm is a bit depressing.... any chance you can come up with something more fun if you want to change these?

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