Skip to content

Commit 96e73f1

Browse files
added cache invalidation at sign up
1 parent 6013c24 commit 96e73f1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/sentry/seer/autofix/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,19 @@ def is_seer_scanner_rate_limited(project: Project, organization: Organization) -
365365
return is_rate_limited
366366

367367

368+
def get_seer_seat_based_tier_cache_key(organization_id: int) -> str:
369+
"""Get the cache key for seat-based Seer tier check."""
370+
return f"seer:seat-based-tier:{organization_id}"
371+
372+
368373
def is_seer_seat_based_tier_enabled(organization: Organization) -> bool:
369374
"""
370375
Check if organization has Seer seat-based pricing via billing.
371376
"""
372377
if features.has("organizations:triage-signals-v0-org", organization):
373378
return True
374379

375-
cache_key = f"seer:seat-based-tier:{organization.id}"
380+
cache_key = get_seer_seat_based_tier_cache_key(organization.id)
376381
cached_value = cache.get(cache_key)
377382
if cached_value is not None:
378383
return cached_value

src/sentry/tasks/autofix.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
bulk_get_project_preferences,
1010
bulk_set_project_preferences,
1111
get_autofix_state,
12+
get_seer_seat_based_tier_cache_key,
1213
)
1314
from sentry.tasks.base import instrumented_task
1415
from sentry.taskworker.namespaces import ingest_errors_tasks, issues_tasks
1516
from sentry.taskworker.retry import Retry
17+
from sentry.utils.cache import cache
1618

1719
logger = logging.getLogger(__name__)
1820

@@ -123,6 +125,9 @@ def configure_seer_for_existing_org(organization_id: int) -> None:
123125
# Set org-level options
124126
organization.update_option("sentry:enable_seer_coding", True)
125127

128+
# If the key exists, invalidate the seat-based tier cache so new settings take effect immediately
129+
cache.delete(f"seer:seat-based-tier:{organization_id}")
130+
126131
projects = list(Project.objects.filter(organization_id=organization_id, status=0))
127132
project_ids = [p.id for p in projects]
128133

@@ -158,3 +163,6 @@ def configure_seer_for_existing_org(organization_id: int) -> None:
158163
)
159164
if len(preferences_to_set) > 0:
160165
bulk_set_project_preferences(organization_id, preferences_to_set)
166+
167+
# Invalidate seat-based tier cache so new settings take effect immediately
168+
cache.delete(get_seer_seat_based_tier_cache_key(organization_id))

0 commit comments

Comments
 (0)