Enhance Club Feature Consumption Logic and Update Versioning
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 47s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m40s
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 47s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m40s
- Introduced the `consume_club_feature_with_usage` function to standardize feature consumption across endpoints, improving code reusability and clarity. - Implemented `merge_feature_usage_into_response` to embed feature usage data in API responses, streamlining frontend integration. - Updated various backend routers to utilize the new consumption logic, ensuring consistent feature usage tracking during AI-related actions. - Enhanced tests to validate the new consumption and logging behavior. - Incremented application version to 0.8.199 and updated module version for 'club_features' to 1.6.0 to reflect these changes.
This commit is contained in:
1 parent
40641594ac
commit
b68185842e
9 files changed
+323
-16
No files matched your search
@@ -9,7 +9,12 @@ from planning_exercise_suggest import PlanningExerciseSuggestRequest, suggest_pl
|
||||
from planning_exercise_path_builder import ProgressionPathSuggestRequest, suggest_progression_path
|
||||
from account_lifecycle import assert_min_account_state
|
||||
from capabilities import probe_capability
|
||||
from club_features import consume_club_feature, probe_club_feature_access, resolve_club_id_for_probe
|
||||
from club_features import (
|
||||
consume_club_feature_with_usage,
|
||||
merge_feature_usage_into_response,
|
||||
probe_club_feature_access,
|
||||
resolve_club_id_for_probe,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix="/api/planning", tags=["planning_exercise_suggest"])
|
||||
|
||||
@@ -42,14 +47,17 @@ def post_planning_exercise_suggest(
|
||||
cur = get_cursor(conn)
|
||||
result = suggest_planning_exercises(cur, tenant=tenant, body=body)
|
||||
if uses_ai:
|
||||
consume_club_feature(
|
||||
usage = consume_club_feature_with_usage(
|
||||
feature_id="ai_calls",
|
||||
club_id=club_id,
|
||||
profile_id=tenant.profile_id,
|
||||
portal_role=tenant.global_role,
|
||||
action="planning_suggest",
|
||||
cur=cur,
|
||||
tenant=tenant,
|
||||
conn=conn,
|
||||
)
|
||||
result = merge_feature_usage_into_response(result, usage)
|
||||
return result
|
||||
|
||||
|
||||
@@ -87,12 +95,15 @@ def post_progression_path_suggest(
|
||||
cur = get_cursor(conn)
|
||||
result = suggest_progression_path(cur, tenant=tenant, body=body)
|
||||
if uses_ai:
|
||||
consume_club_feature(
|
||||
usage = consume_club_feature_with_usage(
|
||||
feature_id="ai_calls",
|
||||
club_id=club_id,
|
||||
profile_id=tenant.profile_id,
|
||||
portal_role=tenant.global_role,
|
||||
action="progression_path_suggest",
|
||||
cur=cur,
|
||||
tenant=tenant,
|
||||
conn=conn,
|
||||
)
|
||||
result = merge_feature_usage_into_response(result, usage)
|
||||
return result
|
||||
Reference in new issue
Block a user