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

Write script_id when creating new ChannelTokens #39855

Merged

Conversation

maureensturgeon
Copy link
Contributor

@maureensturgeon maureensturgeon commented Apr 1, 2021

Updates find_or_create_channel_token to take a script_id which is used only when creating a new channel_token record. All methods calling find_or_create_channel_token are updated accordingly. Note that querying for channel_tokens remains unchanged for now until we have backfilled all the records with empty script_ids.

Links

Testing story

Added unit tests & tested locally that starting work on a channel-backed level stores the script id and that channel-backed levels that had work done on them previously load as expected.

Follow-up work

Next up is writing script_id backfills for the existing channel_token records. For the full list of tasks see https://codedotorg.atlassian.net/browse/LP-1395.

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@maureensturgeon maureensturgeon force-pushed the maureen/LP-1838-channel-tokens-script-id branch from 17d6417 to 12e147e Compare June 25, 2021 17:34
@maureensturgeon maureensturgeon force-pushed the maureen/LP-1838-channel-tokens-script-id branch 2 times, most recently from a6de371 to c220548 Compare July 30, 2021 16:31
Base automatically changed from maureen/LP-1838-channel-tokens-script-id to staging August 2, 2021 16:42
@maureensturgeon maureensturgeon force-pushed the maureen/LP-1842-channel-tokens-write-script-id branch from c63ea2e to 9a34d9a Compare August 23, 2021 19:40
@maureensturgeon maureensturgeon marked this pull request as ready for review August 23, 2021 23:08
@jamescodeorg
Copy link
Contributor

Do we currently have any levels that are shared between scripts (i.e. do we currently have a "live" instance of this bug)?

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@@ -178,7 +179,7 @@ def app_options

if (@level.channel_backed? && params[:action] != 'edit_blocks') || @level.is_a?(Javalab)
view_options(
channel: get_channel_for(@level, @user),
channel: get_channel_for(@level, @script&.id, @user),
Copy link
Member

Choose a reason for hiding this comment

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

from the Jira epic, it looks like you are planning to add a not-null constraint on script_id in the future. This suggests to me that you'll need to come up with a plan for what to do on lines like this for when @script is nil. cases which come to mind include (1) standalone projects, and (2) when viewing a level by id in levelbuilder mode. I'm not sure we have tests covering the latter. I'll see if I can add one.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the ticket with the non-null constraint was resolved with status "won't do" https://codedotorg.atlassian.net/browse/LP-1846, for reason number 2 that you mentioned which is that in levelbuilder we'll be able to view a level that's channel-backed outside of the context of a script so script_id will be nil.

Copy link
Member

Choose a reason for hiding this comment

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

Great! No concerns with instances of @script&.id, then 👍

@maureensturgeon
Copy link
Contributor Author

Do we currently have any levels that are shared between scripts (i.e. do we currently have a "live" instance of this bug)?

Yes, check out the comments in this ticket with an example https://codedotorg.atlassian.net/browse/LP-1752

assert_equal expected_channel_token.id, channel_token.id
end

test 'find_or_create_channel_token will create a new channel token with script_id if no channel token exists' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Note for future PR: If we decide that passing in nil as the script_id is a valid scenario, let's add a test for it.

@maureensturgeon maureensturgeon merged commit c24825f into staging Aug 25, 2021
@maureensturgeon maureensturgeon deleted the maureen/LP-1842-channel-tokens-write-script-id branch August 25, 2021 17:03
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.

None yet

3 participants