Skip to content

Commit 60f7ea4

Browse files
HenryHenry
authored andcommitted
fix: load admin orders from billing plans
1 parent b277e53 commit 60f7ea4

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

backend_api_python/app/routes/user.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,6 +1771,9 @@ def _admin_order_filters(status_filter: str, payment_method: str, plan_filter: s
17711771
return ("WHERE " + " AND ".join(conditions)) if conditions else "", params
17721772

17731773

1774+
_ADMIN_PLAN_TABLE = "qd_billing_plans"
1775+
1776+
17741777
@user_blp.route('/admin-orders', methods=['GET'])
17751778
@login_required
17761779
@admin_required
@@ -1789,10 +1792,10 @@ def get_admin_orders():
17891792
where_sql, filter_params = _admin_order_filters(
17901793
status_filter, payment_method, plan_filter, search,
17911794
)
1792-
joined_source = """
1795+
joined_source = f"""
17931796
FROM unified_orders o
17941797
LEFT JOIN qd_users u ON u.id = o.user_id
1795-
LEFT JOIN qd_membership_plans p ON p.code = o.plan
1798+
LEFT JOIN {_ADMIN_PLAN_TABLE} p ON p.code = o.plan
17961799
"""
17971800

17981801
with get_db_connection() as db:

backend_api_python/tests/test_admin_order_filters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from app.routes.user import _ADMIN_ORDERS_CTE, _admin_order_filters
1+
from app.routes.user import _ADMIN_ORDERS_CTE, _ADMIN_PLAN_TABLE, _admin_order_filters
22

33

44
def test_admin_orders_unify_crypto_and_stripe_sources():
@@ -8,6 +8,10 @@ def test_admin_orders_unify_crypto_and_stripe_sources():
88
assert "stripe_session_id" in _ADMIN_ORDERS_CTE
99

1010

11+
def test_admin_orders_join_the_database_backed_billing_plan_table():
12+
assert _ADMIN_PLAN_TABLE == "qd_billing_plans"
13+
14+
1115
def test_admin_order_filters_cover_method_plan_status_and_search():
1216
where_sql, params = _admin_order_filters(
1317
"paid", "usdc", "yearly", "STRIPE-42"

0 commit comments

Comments
 (0)