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

PlanService updates for GitLab #461

Merged
merged 2 commits into from
Jan 15, 2025
Merged

PlanService updates for GitLab #461

merged 2 commits into from
Jan 15, 2025

Conversation

nora-codecov
Copy link
Contributor

@nora-codecov nora-codecov commented Jan 3, 2025

update PlanService so GitLab orgs use the root org's plan, fold is_pr_billing_plan into PlanService

IF an OwnerOrg is a GitLab subgroup OR has an Account, the plan on the OwnerOrg is not the one we want to use! We want the plan on the root Org or Account object instead.

PlanService already had the smarts to check for an Account and get the Account plan, but now it also has the smarts to check whether a GitLab OwnerOrg has a parent, then use the plan from the root Org.

Part of codecov/engineering-team#2710

@nora-codecov nora-codecov requested review from RulaKhaled, ajay-sentry and a team January 3, 2025 01:15
SENTRY_MONTHLY = "users-sentrym"
SENTRY_YEARLY = "users-sentryy"
SENTRY_MONTHLY = "users-sentrym" # not in BillingPlan
SENTRY_YEARLY = "users-sentryy" # not in BillingPlan
Copy link
Contributor Author

Choose a reason for hiding this comment

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

does anyone know why these Plans aren't in the BillingPlan enum? Seems like an oversight...
@ajay-sentry @RulaKhaled since you two have been in the PlanService lately 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked with Ajay, this is an oversight, adding to BillingPlan

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.93%. Comparing base (98a9a16) to head (b5dc7eb).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #461      +/-   ##
==========================================
- Coverage   90.28%   89.93%   -0.35%     
==========================================
  Files         427      324     -103     
  Lines       12836     9162    -3674     
  Branches     2107     1630     -477     
==========================================
- Hits        11589     8240    -3349     
+ Misses       1137      859     -278     
+ Partials      110       63      -47     
Flag Coverage Δ
shared-docker-uploader ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -37,6 +37,7 @@ def is_enterprise_cloud_plan(plan: BillingPlan) -> bool:


def is_pr_billing_plan(plan: str) -> bool:
# use is_pr_billing_plan() in PlanService instead of accessing this directly
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's worth to mark it as deprecated?

self.current_org = current_org
if (
current_org.service == Service.GITLAB.value
and current_org.parent_service_id
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem correct... you are checking for current_org.parent_service_id not being None, but self.current_org is getting the value of current_org.root_organization

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's correct, just confusing 🙃
We want the root org. The way you know if the current_org is the root org is parent_service_id field.
if current_org.parent_service_id, it means it is not the root org.
parent and root are not necessarily the same org - GL orgs can have multiple levels of groups and subgroups.
So if you know that you don't have the root org (by checking current_org.parent_service_id), then get the root org with .root_organization, a helper function on the model.

@nora-codecov nora-codecov force-pushed the nora/2710 branch 2 times, most recently from 9e55b8a to 990c398 Compare January 8, 2025 18:48
@nora-codecov nora-codecov added this pull request to the merge queue Jan 15, 2025
Merged via the queue into main with commit 191837f Jan 15, 2025
6 checks passed
@nora-codecov nora-codecov deleted the nora/2710 branch January 15, 2025 17:59
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