-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(ui-components): adds skip_load_on_open field and adds migration #20078
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ba13c01
adds skip_load_on_open field and adds migration
scefali dfd684e
Fix test
scefali 87e5eba
merge from master
scefali 1af3dbc
update comments
scefali 9396669
update test
3c0db10
update test
dc4b6f6
merge from master
037cac3
fix migrations
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/sentry/migrations/0096_sentry_app_component_skip_load_on_open.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.11.29 on 2020-07-28 22:38 | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.db import migrations | ||
|
|
||
| #update the field with mutation | ||
| def convert_field(field): | ||
| # even if async if false, we had a bug where we'd treat it the same as true | ||
| # so to maintain legacy behavior, we have to replicate that same check when setting skip_load_on_open | ||
| if "async" in field: | ||
| field["skip_load_on_open"] = True | ||
| del field["async"] | ||
|
|
||
|
|
||
| # updates the schema with mutation | ||
| def update_element_schema(schema): | ||
| # update all the fields in the schema | ||
| link = schema.get("link", {}) | ||
| create = schema.get("create", {}) | ||
|
|
||
| for field in link.get("required_fields", []): | ||
| convert_field(field) | ||
|
|
||
| for field in link.get("optional_fields", []): | ||
| convert_field(field) | ||
|
|
||
| for field in create.get("required_fields", []): | ||
| convert_field(field) | ||
|
|
||
| for field in create.get("optional_fields", []): | ||
| convert_field(field) | ||
|
|
||
| def update_ui_components(apps, schema_editor): | ||
| SentryAppComponent = apps.get_model("sentry", "SentryAppComponent") | ||
| for component in SentryAppComponent.objects.filter(type="issue-link").select_related("sentry_app"): | ||
| # need to update the denormalized data | ||
| update_element_schema(component.schema) | ||
| for element in component.sentry_app.schema.get("elements", []): | ||
| # only update issue link elements | ||
| if element.get("type") == "issue-link": | ||
| update_element_schema(element) | ||
|
|
||
| # save the UI component and the sentry app | ||
| component.save() | ||
| component.sentry_app.save() | ||
|
|
||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| # This flag is used to mark that a migration shouldn't be automatically run in | ||
| # production. We set this to True for operations that we think are risky and want | ||
| # someone from ops to run manually and monitor. | ||
| # General advice is that if in doubt, mark your migration as `is_dangerous`. | ||
| # Some things you should always mark as dangerous: | ||
| # - Large data migrations. Typically we want these to be run manually by ops so that | ||
| # they can be monitored. Since data migrations will now hold a transaction open | ||
| # this is even more important. | ||
| # - Adding columns to highly active tables, even ones that are NULL. | ||
| is_dangerous = False | ||
|
|
||
| # This flag is used to decide whether to run this migration in a transaction or not. | ||
| # By default we prefer to run in a transaction, but for migrations where you want | ||
| # to `CREATE INDEX CONCURRENTLY` this needs to be set to False. Typically you'll | ||
| # want to create an index concurrently when adding one to an existing table. | ||
| atomic = False | ||
|
|
||
|
|
||
| dependencies = [ | ||
| ('sentry', '0095_ruleactivity'), | ||
| ] | ||
|
|
||
| operations = [migrations.RunPython(update_ui_components, migrations.RunPython.noop)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think we could add these options in the
test_issue_linktest?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MeredithAnya Which test is this? can't find it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validators/sentry_apps/test_issue_link.pyp sureThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MeredithAnya My bad, I didn't realize it was a file. Yes, I will update it.