Skip to content

Music: proposal for LevelData variants#52570

Merged
breville merged 5 commits into
music-standalone-video-levelsfrom
music-standalone-video-levels-with-video-data-as-level-data
Jul 3, 2023
Merged

Music: proposal for LevelData variants#52570
breville merged 5 commits into
music-standalone-video-levelsfrom
music-standalone-video-levels-with-video-data-as-level-data

Conversation

@breville

@breville breville commented Jul 2, 2023

Copy link
Copy Markdown
Member

No description provided.

@breville breville marked this pull request as draft July 2, 2023 03:45

@merged_properties = @level.properties.camelize_keys.merge({video: @video&.camelize_keys})
@properties = @level.properties.camelize_keys
@properties[:levelData] = @video if @video

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was also thinking about this for a separate change; as this gets more complex, should we just add a summarize_for_lab2 function on level.rb where we can craft the structure of the payload we want to send, and move the logic out of the controller?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, that is a good idea, and definitely the right path forward.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added a summarize_for_labs2_properties, though flexible on naming.

Comment thread apps/src/labs/types.ts Outdated
export interface LevelVideo {
// The level data for a standalone_video level that doesn't require
// reloads between levels.
export interface LevelDataVideo {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we instead make this a VideoLevelData that extends LevelData, similar to MusicLevelData? That way the video specific properties can live closer to the video specific components?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should anything belong in LevelData in that case? It feels like text, validations, and startSources are rather specific to be in there...

@sanchitmalhotra126 sanchitmalhotra126 Jul 3, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, yeah I felt like text/validations/startSources were somewhat generic, but i guess they are specific to levels with progress and projects. Maybe we should rename LevelData to ProjectLevelData? Then yeah we can keep it like you have it where type LevelData = ProjectLevelData | VideoLevelData. Not sure what's best but I'm sure we'll refine this as we support different level types

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done!

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

}
end

def summarize_for_lab2_properties

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: mind adding a doc for reference here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call; done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, and just realized, we'd need to update levels_controller with this as well right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point. Just fixed in parent branch.

As it happens, the individual level pages still worked fine because we didn't change what level_properties returns for a music level, and we're using the legacy server-rendered page for a standalone video.

@breville breville marked this pull request as ready for review July 3, 2023 22:22
@breville breville merged commit 434c787 into music-standalone-video-levels Jul 3, 2023
@breville breville deleted the music-standalone-video-levels-with-video-data-as-level-data branch July 3, 2023 22:22
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