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

Fix/thk playlists #1099

Merged
merged 7 commits into from
Jun 12, 2024
Merged

Fix/thk playlists #1099

merged 7 commits into from
Jun 12, 2024

Conversation

BeritJanssen
Copy link
Collaborator

This branch fixes remaining issues with playlist validation of Toontjehoger rules files.
It also implements a much simplified strategy for picking sections and giving feedback in ToontjeHogerKids5Tempo.

Copy link

sentry-io bot commented Jun 11, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: backend/experiment/rules/toontjehoger_2_preverbal.py

Function Unhandled Issue
validate_playlist TypeError: '<' not supported between instances of 'dict' and 'dict' /server/admin/experiment/experiment/...
Event Count: 2

Did you find this useful? React with a 👍 or 👎

@BeritJanssen BeritJanssen self-assigned this Jun 11, 2024
@@ -199,15 +199,16 @@ def validate_playlist_groups(self, groups):
# Check if the groups are sequential and unique
integer_groups.sort()
if integer_groups != list(range(1, len(groups) + 1)):
return ['Groups in playlist sections should be sequential numbers starting from 1 to the number of sections in the playlist ({}). E.g. "1, 2, 3, ... {}"'.format(len(groups), len(groups))]
return ['Groups in playlist sections should be sequential numbers starting from 1 to the number of items in the playlist ({}). E.g. "1, 2, 3, ... {}"'.format(self.PLAYLIST_ITEMS, self.PLAYLIST_ITEMS)]
Copy link
Contributor

Choose a reason for hiding this comment

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

While the original Toontjehoger Absolute game has 13 playlist items, this validator should be flexible: it should be entirely possible to implement ToontjeHoger Absolute with less playlist items, without having to override the validator.

I thought this validator should be flexible, or have I misunderstood what you wrote? 😄

Copy link
Collaborator Author

@BeritJanssen BeritJanssen Jun 12, 2024

Choose a reason for hiding this comment

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

This was a misunderstanding indeed: with "playlist items" I meant, "items, of which there are three variants". So n_sections != self.PLAYLIST_ITEMS. Hurrying through code reviews is not a good idea, I should've caught this before.


return []

def validate_playlist(self, playlist: Playlist):
errors = super().validate_playlist(playlist)

# Get group values from sections, ordered by group
groups = list(playlist.section_set.values_list('group', flat=True))
groups = list(playlist.section_set.values_list(
'group', flat=True).distinct())
Copy link
Collaborator Author

@BeritJanssen BeritJanssen Jun 12, 2024

Choose a reason for hiding this comment

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

This is the actual needed change though - before, there were as many groups as there were sections. I still think the reference to PLAYLIST_ITEMS in the validate_playlist_groups function is more readable.

@BeritJanssen BeritJanssen merged commit 63a6be7 into develop Jun 12, 2024
10 checks passed
@BeritJanssen BeritJanssen deleted the fix/thk-playlists branch June 12, 2024 08:23
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