(self, request, format=None)
| 2480 | deprecated=True, |
| 2481 | ) |
| 2482 | def get(self, request, format=None): |
| 2483 | organization = request.organization |
| 2484 | result, success = fast_api_key_validation_and_cache(request) |
| 2485 | if not success: |
| 2486 | return result |
| 2487 | else: |
| 2488 | organization_pk = result |
| 2489 | serializer = GetCustomerEventAccessRequestSerializer( |
| 2490 | data=request.query_params, context={"organization_pk": organization_pk} |
| 2491 | ) |
| 2492 | serializer.is_valid(raise_exception=True) |
| 2493 | try: |
| 2494 | username = self.request.user.username |
| 2495 | except Exception: |
| 2496 | username = None |
| 2497 | posthog.capture( |
| 2498 | POSTHOG_PERSON |
| 2499 | if POSTHOG_PERSON |
| 2500 | else ( |
| 2501 | username if username else organization.organization_name + " (Unknown)" |
| 2502 | ), |
| 2503 | event="DEPRECATED_get_metric_access", |
| 2504 | properties={"organization": organization.organization_name}, |
| 2505 | ) |
| 2506 | customer = serializer.validated_data["customer"] |
| 2507 | event_name = serializer.validated_data.get("event_name") |
| 2508 | access_metric = serializer.validated_data.get("metric") |
| 2509 | subscription_records = ( |
| 2510 | SubscriptionRecord.objects.active() |
| 2511 | .select_related("billing_plan") |
| 2512 | .filter( |
| 2513 | organization_id=organization_pk, |
| 2514 | customer=customer, |
| 2515 | ) |
| 2516 | ) |
| 2517 | subscription_filters = { |
| 2518 | x["property_name"]: x["value"] |
| 2519 | for x in serializer.validated_data.get("subscription_filters", []) |
| 2520 | } |
| 2521 | for key, value in subscription_filters.items(): |
| 2522 | subscription_records = subscription_records.filter( |
| 2523 | subscription_filters__contains=[[key, value]] |
| 2524 | ) |
| 2525 | metrics = [] |
| 2526 | subscription_records = subscription_records.prefetch_related( |
| 2527 | "billing_plan__plan_components", |
| 2528 | "billing_plan__plan_components__billable_metric", |
| 2529 | "billing_plan__plan_components__tiers", |
| 2530 | ) |
| 2531 | for sr in subscription_records: |
| 2532 | subscription_filters = [] |
| 2533 | for filter_arr in sr.subscription_filters: |
| 2534 | subscription_filters.append( |
| 2535 | { |
| 2536 | "property_name": filter_arr[0], |
| 2537 | "value": filter_arr[1], |
| 2538 | } |
| 2539 | ) |
nothing calls this directly
no test coverage detected