Skip to content

migrations(insights): backfill user starred transactions from team starred transactions #93327

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

Conversation

DominikB2014
Copy link
Contributor

@DominikB2014 DominikB2014 commented Jun 11, 2025

Migrate team based transactions (teamkeytransaction) to user based transactions (insightsStarredSegments)

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 11, 2025
Copy link
Contributor

This PR has a migration; here is the generated SQL for src/sentry/insights/migrations/0002_backfill_team_starred.py

for 0002_backfill_team_starred in insights

--
-- Raw Python operation
--
-- THIS OPERATION CANNOT BE WRITTEN AS SQL

Copy link

codecov bot commented Jun 11, 2025

Codecov Report

Attention: Patch coverage is 96.36364% with 2 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../insights/migrations/0002_backfill_team_starred.py 92.85% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #93327       +/-   ##
===========================================
+ Coverage   45.48%   88.00%   +42.52%     
===========================================
  Files       10242    10301       +59     
  Lines      591046   594252     +3206     
  Branches    23000    23000               
===========================================
+ Hits       268812   522963   +254151     
+ Misses     321743    70798   -250945     
  Partials      491      491               

@DominikB2014 DominikB2014 marked this pull request as ready for review June 12, 2025 16:03
@DominikB2014 DominikB2014 requested a review from a team as a code owner June 12, 2025 16:03
@DominikB2014
Copy link
Contributor Author

@markstory @wedamija Thanks a lot for all the comments! I made all the changes, if you could have another look that would be awesome

Comment on lines +29 to +31
user_ids = OrganizationMemberTeam.objects.filter(team=projectTeam.team).values_list(
"organizationmember__user_id", flat=True
)
Copy link
Member

Choose a reason for hiding this comment

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

You could use team_id=projectTeam.team_id here which would let you skip loading the Team record as well. But what you have will work fine. There isn't enough data in TeamKeyTransaction to make an meaningful difference in runtime.

Copy link
Contributor Author

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.

👍

@DominikB2014 DominikB2014 merged commit 709609d into master Jun 16, 2025
64 checks passed
@DominikB2014 DominikB2014 deleted the dominikbuszowiecki/dain-418-migrate-team-starred-transactions-to-user-based-starred branch June 16, 2025 14:55
Copy link

sentry-io bot commented Jun 17, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ IntegrityError: NotNullViolation('null value in column "user_id" of relation "insights_starred_segments" violates not-null constraint\nDETAIL: Failing row contains (525, 2025-06-17 17:26:01.06358+00, 2025-06-17 17:26:01.063584+00, null, HomepageTotalTakings, 450705921... sentry.insights.migrations.0002_backfill_team_s... View Issue

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

billyvg pushed a commit that referenced this pull request Jun 18, 2025
…arred transactions (#93327)

Migrate team based transactions (teamkeytransaction) to user based
transactions (insightsStarredSegments)
andrewshie-sentry pushed a commit that referenced this pull request Jun 19, 2025
…arred transactions (#93327)

Migrate team based transactions (teamkeytransaction) to user based
transactions (insightsStarredSegments)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants