Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit db54697

Browse files
authored
feat: Add is___plan fields to plan resolver (#1039)
1 parent 7749e0b commit db54697

File tree

5 files changed

+82
-18
lines changed

5 files changed

+82
-18
lines changed

graphql_api/tests/test_plan.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def test_owner_plan_data_when_trialing(self):
5858
monthlyUploadLimit
5959
pretrialUsersCount
6060
planUserCount
61+
isEnterprisePlan
62+
isFreePlan
63+
isProPlan
64+
isSentryPlan
65+
isTeamPlan
66+
isTrialPlan
6167
}
6268
}
6369
}
@@ -83,6 +89,12 @@ def test_owner_plan_data_when_trialing(self):
8389
"monthlyUploadLimit": None,
8490
"pretrialUsersCount": 234,
8591
"planUserCount": 123,
92+
"isEnterprisePlan": False,
93+
"isFreePlan": False,
94+
"isProPlan": False,
95+
"isSentryPlan": False,
96+
"isTeamPlan": False,
97+
"isTrialPlan": True,
8698
}
8799

88100
def test_owner_plan_data_with_account(self):
@@ -101,6 +113,12 @@ def test_owner_plan_data_with_account(self):
101113
billingRate
102114
baseUnitPrice
103115
planUserCount
116+
isEnterprisePlan
117+
isFreePlan
118+
isProPlan
119+
isSentryPlan
120+
isTeamPlan
121+
isTrialPlan
104122
}
105123
}
106124
}
@@ -114,6 +132,12 @@ def test_owner_plan_data_with_account(self):
114132
"billingRate": "annually",
115133
"baseUnitPrice": 10,
116134
"planUserCount": 25,
135+
"isEnterprisePlan": False,
136+
"isFreePlan": False,
137+
"isProPlan": True,
138+
"isSentryPlan": False,
139+
"isTeamPlan": False,
140+
"isTrialPlan": False,
117141
}
118142

119143
def test_owner_plan_data_has_seats_left(self):
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
type Plan {
2-
trialStatus: TrialStatus!
3-
trialStartDate: DateTime
4-
trialEndDate: DateTime
5-
trialTotalDays: Int
6-
pretrialUsersCount: Int
2+
baseUnitPrice: Int!
3+
benefits: [String!]!
4+
billingRate: String
5+
hasSeatsLeft: Boolean!
6+
isEnterprisePlan: Boolean!
7+
isFreePlan: Boolean!
8+
isProPlan: Boolean!
9+
isSentryPlan: Boolean!
10+
isTeamPlan: Boolean!
11+
isTrialPlan: Boolean!
712
marketingName: String!
13+
monthlyUploadLimit: Int
814
planName: String!
915
@deprecated(
1016
reason: "Plan representations have used `value` for a while, making the frontend code hard to change"
1117
)
12-
value: String!
13-
tierName: String!
14-
billingRate: String
15-
baseUnitPrice: Int!
16-
benefits: [String!]!
17-
monthlyUploadLimit: Int
1818
planUserCount: Int
19-
hasSeatsLeft: Boolean!
19+
pretrialUsersCount: Int
20+
tierName: String!
21+
trialEndDate: DateTime
22+
trialStartDate: DateTime
23+
trialStatus: TrialStatus!
24+
trialTotalDays: Int
25+
value: String!
2026
}

graphql_api/types/plan/plan.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
from typing import List, Optional
33

44
from ariadne import ObjectType
5-
from shared.plan.constants import (
6-
TrialStatus,
7-
)
5+
from shared.plan.constants import PlanBillingRate, TrialStatus
86
from shared.plan.service import PlanService
97

108
from codecov.db import sync_to_async
@@ -59,7 +57,7 @@ def resolve_tier_name(plan_service: PlanService, info) -> str:
5957

6058
@plan_bindable.field("billingRate")
6159
@sync_to_async
62-
def resolve_billing_rate(plan_service: PlanService, info) -> Optional[str]:
60+
def resolve_billing_rate(plan_service: PlanService, info) -> Optional[PlanBillingRate]:
6361
return plan_service.billing_rate
6462

6563

@@ -98,3 +96,39 @@ def resolve_plan_user_count(plan_service: PlanService, info) -> int:
9896
@sync_to_async
9997
def resolve_has_seats_left(plan_service: PlanService, info) -> bool:
10098
return plan_service.has_seats_left
99+
100+
101+
@plan_bindable.field("isEnterprisePlan")
102+
@sync_to_async
103+
def resolve_is_enterprise_plan(plan_service: PlanService, info) -> bool:
104+
return plan_service.is_enterprise_plan
105+
106+
107+
@plan_bindable.field("isFreePlan")
108+
@sync_to_async
109+
def resolve_is_free_plan(plan_service: PlanService, info) -> bool:
110+
return plan_service.is_free_plan
111+
112+
113+
@plan_bindable.field("isProPlan")
114+
@sync_to_async
115+
def resolve_is_pro_plan(plan_service: PlanService, info) -> bool:
116+
return plan_service.is_pro_plan
117+
118+
119+
@plan_bindable.field("isSentryPlan")
120+
@sync_to_async
121+
def resolve_is_sentry_plan(plan_service: PlanService, info) -> bool:
122+
return plan_service.is_sentry_plan
123+
124+
125+
@plan_bindable.field("isTeamPlan")
126+
@sync_to_async
127+
def resolve_is_team_plan(plan_service: PlanService, info) -> bool:
128+
return plan_service.is_team_plan
129+
130+
131+
@plan_bindable.field("isTrialPlan")
132+
@sync_to_async
133+
def resolve_is_trial_plan(plan_service: PlanService, info) -> bool:
134+
return plan_service.is_trial_plan

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ freezegun
2626
google-cloud-pubsub
2727
gunicorn>=22.0.0
2828
https://github.com/codecov/opentelem-python/archive/refs/tags/v0.0.4a1.tar.gz#egg=codecovopentelem
29-
https://github.com/codecov/shared/archive/22622868034aa8dbaad88901ba7156e3ae6b9539.tar.gz#egg=shared
29+
https://github.com/codecov/shared/archive/1c4ca00e35d95d1281e0415ce1897f6dbbc6368a.tar.gz#egg=shared
3030
https://github.com/photocrowd/django-cursor-pagination/archive/f560902696b0c8509e4d95c10ba0d62700181d84.tar.gz
3131
idna>=3.7
3232
minio

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ sentry-sdk[celery]==2.13.0
414414
# shared
415415
setproctitle==1.1.10
416416
# via -r requirements.in
417-
shared @ https://github.com/codecov/shared/archive/22622868034aa8dbaad88901ba7156e3ae6b9539.tar.gz
417+
shared @ https://github.com/codecov/shared/archive/1c4ca00e35d95d1281e0415ce1897f6dbbc6368a.tar.gz
418418
# via -r requirements.in
419419
simplejson==3.17.2
420420
# via -r requirements.in

0 commit comments

Comments
 (0)