Skip to content

armgit / mwmbl

Public Imported from GitHub
0

An open source, non-profit web search engine

Set Combined Search limits to 30 free, 300 Sprout, 1,500 Sapling and Canopy

Claude5c4834df19fa
diff --git a/mwmbl/membership.py b/mwmbl/membership.py
index ec9152e..4f98519 100644
--- a/mwmbl/membership.py
+++ b/mwmbl/membership.py
@@ -60,10 +60,11 @@ def tier_for_product(product_id: str) -> MembershipTier | None:
# Combined Search queries a month for web (JWT) callers, by tier. Signed-in users without a
-# membership, and tiers not listed, get COMBINED_SEARCH_MONTHLY_LIMIT.
+# membership get COMBINED_SEARCH_MONTHLY_LIMIT.
COMBINED_SEARCH_MONTHLY_LIMITS = {
- MembershipTier.SAPLING: 1_000,
- MembershipTier.CANOPY: 1_000,
+ MembershipTier.SPROUT: 300,
+ MembershipTier.SAPLING: 1_500,
+ MembershipTier.CANOPY: 1_500,
}
diff --git a/mwmbl/settings_common.py b/mwmbl/settings_common.py
index 44960dc..c8cc4dc 100644
--- a/mwmbl/settings_common.py
+++ b/mwmbl/settings_common.py
@@ -292,7 +292,7 @@ CURRENT_AGREEMENT_VERSIONS = {
# ranks the union with its own LTR model. Gated behind login, like Super Search, which it is
# meant to replace. This is the monthly limit for signed-in users without a membership;
# member tiers get more - see mwmbl.membership.COMBINED_SEARCH_MONTHLY_LIMITS.
-COMBINED_SEARCH_MONTHLY_LIMIT = 100
+COMBINED_SEARCH_MONTHLY_LIMIT = 30
# Its own model artifact, so Combined Search can be retrained on the pooled candidate set
# without moving standard search's ranking. Falls back to RUST_MODEL_PATH until trained.
COMBINED_MODEL_PATH = Path(__file__).parent / "resources" / "model-combined.xgb"
diff --git a/test/test_combined_search.py b/test/test_combined_search.py
index e0395be..b2b0250 100644
--- a/test/test_combined_search.py
+++ b/test/test_combined_search.py
@@ -212,10 +212,9 @@ def _join(user, tier):
@pytest.mark.django_db
-@override_settings(COMBINED_SEARCH_MONTHLY_LIMIT=100)
@pytest.mark.parametrize(
"tier, limit",
- [(None, 100), (MembershipTier.SPROUT, 100), (MembershipTier.SAPLING, 1_000), (MembershipTier.CANOPY, 1_000)],
+ [(None, 30), (MembershipTier.SPROUT, 300), (MembershipTier.SAPLING, 1_500), (MembershipTier.CANOPY, 1_500)],
)
def test_the_limit_is_set_by_the_membership_tier(client, user, access_token, fresh_quota, stub_sources, tier, limit):
stub_sources()
@@ -233,7 +232,6 @@ def test_the_limit_is_set_by_the_membership_tier(client, user, access_token, fre
@pytest.mark.django_db
-@override_settings(COMBINED_SEARCH_MONTHLY_LIMIT=100)
def test_the_usage_endpoint_reports_the_members_quota(client, user, access_token, fresh_quota):
_join(user, MembershipTier.SAPLING)
cache.set(_combined_search_monthly_key(user.id), 7, timeout=3600)
@@ -241,15 +239,14 @@ def test_the_usage_endpoint_reports_the_members_quota(client, user, access_token
response = client.get(USAGE_URL, HTTP_AUTHORIZATION=f"Bearer {access_token}")
assert response.status_code == 200
- assert response.json() == {"monthly_usage": 7, "monthly_limit": 1_000}
+ assert response.json() == {"monthly_usage": 7, "monthly_limit": 1_500}
@pytest.mark.django_db
-@override_settings(COMBINED_SEARCH_MONTHLY_LIMIT=100)
def test_the_usage_endpoint_reports_the_default_quota_for_a_non_member(client, access_token, fresh_quota):
response = client.get(USAGE_URL, HTTP_AUTHORIZATION=f"Bearer {access_token}")
- assert response.json() == {"monthly_usage": 0, "monthly_limit": 100}
+ assert response.json() == {"monthly_usage": 0, "monthly_limit": 30}
@pytest.mark.django_db