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

Added a new event enum value, "Festival" #1199

Merged
merged 4 commits into from
Sep 1, 2022

Conversation

kateabr
Copy link
Contributor

@kateabr kateabr commented Aug 16, 2022

@kateabr
Copy link
Contributor Author

kateabr commented Aug 16, 2022

VocaDB/community#155

@@ -18,8 +18,9 @@
"Club": "Club",
"Concert": "Concert",
"Contest": "Contest",
"Convention": "Convention",
"Other": "Other",
"Festival": "Festival",
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to update not only json files, but also corresponding resx files on the VocaDB/vocadb-loc repo. These json files are intended to be automatically generated by this script (as part of #900). It would be nice if we could do this automatically at compile time though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/// <summary>
/// J-POP Cover Festival
/// </summary>
Festival = 1 << 7,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please add a unit test for the change? You can use one of the tests in the Tests/Domain folder (depending on whether or not numbers/names can be changed) as a reference. Additionally, can you please enable nullable reference types by removing the #nullable disable directive, and use the file-scoped namespace for this file? You can do this in a separate commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -5,6 +5,7 @@
"Club": "クラブ",
"Concert": "コンサート",
"Contest": "コンテスト",
"Festival": "祭り",
Copy link
Contributor

Choose a reason for hiding this comment

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

Which should we use, "祭" or "祭り"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohh that's a typo, I wanted to write "祭"

Comment on lines 8 to 21
[DataRow(0, EventCategory.Unspecified)]
[DataRow(1, EventCategory.AlbumRelease)]
[DataRow(2, EventCategory.Anniversary)]
[DataRow(4, EventCategory.Club)]
[DataRow(8, EventCategory.Concert)]
[DataRow(16, EventCategory.Contest)]
[DataRow(32, EventCategory.Convention)]
[DataRow(64, EventCategory.Other)]
[DataRow(128, EventCategory.Festival)]
[TestMethod]
public void Value(int expected, EventCategory actual)
{
((int) actual).Should().Be(expected);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the values of the EventCategory enum are saved as a string in DB, and not as a bit field, you should write tests against names instead of numbers (and can you please make sure that?). See PVServiceTests.cs.

Copy link
Contributor Author

@kateabr kateabr Aug 18, 2022

Choose a reason for hiding this comment

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

Forgot to ask: if they are stored as strings, there should be no problem with switching the order of values in the enum class, right? Currently, when selecting event type, "Festival" comes last, while I'd like it to come immediately after "Contest" (I think it makes more sense this way)

Copy link
Contributor

@ycanardeau ycanardeau Aug 20, 2022

Choose a reason for hiding this comment

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

Switching the order may work if and only if you are 100 percent sure that they are never stored as numbers. It would be disastrous if you accidentally changed it. I would suggest switching the order on the frontend instead, just like ArtistTypesDropdownKnockout, because it's more flexible. You could define a varaible like (you may need to convert the EventCategory enum to a string enum first though):

const eventCategoryOrders: Record<EventCategory, number> = {
    [EventCategory.Unspecified]: 1,
    [EventCategory.AlbumRelease]: 2,
   // ...
}

@ycanardeau ycanardeau merged commit 05242d5 into VocaDB:main Sep 1, 2022
@ycanardeau
Copy link
Contributor

Thanks for the PR!

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.

Add a "Festival" event type
2 participants