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

Add annotations and pieces tables #245

Merged
merged 9 commits into from
Feb 21, 2019

Conversation

jaylorch
Copy link
Contributor

This pull request creates the annotations table (for storing per-team, per-puzzle annotations for puzzles that need them) and the pieces table (for storing pieces of a puzzle that teams earn as they make progress). It also creates CRUD pages for the pieces table.

@jaylorch jaylorch requested a review from morganbr February 19, 2019 05:43
Copy link
Contributor

@morganbr morganbr left a comment

Choose a reason for hiding this comment

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

This looks like good progress; a few comments.

Data/Data.csproj Outdated
@@ -13,6 +13,12 @@
<Compile Remove="Migrations\20190214050904_CheatsAndWhistles.cs" />
</ItemGroup>

<ItemGroup>
Copy link
Contributor

Choose a reason for hiding this comment

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

You can undo this (it's just removing files that you no longer have)

/// The annotation contents
/// </summary>
[Required]
[StringLength(255)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is 255 long enough for what you're doing? If you're not sure, you can leave this off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's long enough. I set it intentionally small so that no one could use annotations to store huge amounts of data on our server. Maybe some future puzzle writer will want it longer, but at that point it should be easy to just increase this number.


/// <summary>
/// The minimum progress level for a team at which this piece should be
/// revealed to that team
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace tab with spaces

/// The contents of the piece
/// </summary>
[Required]
[StringLength(4096)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for this limit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really; I'll remove it.

column: x => x.PuzzleID,
principalTable: "Puzzles",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
Copy link
Contributor

Choose a reason for hiding this comment

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

Having cascading deletes for both Puzzle and Team is going to break when it meets up with #243 (which I'll be merging tonight) . You'll need to disable cascading deletes for one of them and manually delete annotations for it. See #243 for examples with PuzzleStatePerTeam.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand.


namespace ServerCore.Pages.Pieces
{
[Authorize(Policy = "IsAuthorOfPuzzle")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto


public async Task<IActionResult> OnGetAsync(int? id)
{
if (id == null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why have a nullable ID if we'd return 404 if it's null?


public async Task<IActionResult> OnPostAsync(int? id)
{
if (id == null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto


namespace ServerCore.Pages.Pieces
{
[Authorize(Policy = "IsAuthorOfPuzzle")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same auth comment

@@ -25,6 +25,11 @@
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="2.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.2" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you add these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The wiki said to follow the instructions at
https://docs.microsoft.com/en-us/ef/core/get-started/install/
to get started with EF Core. Those instructions said to install Microsoft.EntityFrameworkCore.SqlServer and Microsoft.EntityFrameworkCore.Tools. So I did.

I then updated the wiki here to include all those details:
https://github.com/PuzzleServer/mainpuzzleserver/wiki/Local-Development-Environment-Setup

@morganbr morganbr merged commit 1cc9572 into PuzzleServer:master Feb 21, 2019
@jaylorch jaylorch deleted the dev/lorch/sync branch April 2, 2019 01:52
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