Fix feature detection for explore and add community
explore lives at /u/{handle}/athlete/explore/ — was classified as
profile. Add path-contains check so it's detected correctly.
Add community (/community/) which was falling into the feed catchall.
Extend feature map tuples to (host, startswith, contains, label).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+19
-14
@@ -69,18 +69,21 @@ def _is_bot(ua: str, path: str) -> bool:
|
|||||||
# ── Feature mapping (from Referer header) ─────────────────────────────────────
|
# ── Feature mapping (from Referer header) ─────────────────────────────────────
|
||||||
|
|
||||||
# Evaluated in order: first match wins. None label = exclude.
|
# Evaluated in order: first match wins. None label = exclude.
|
||||||
_FEATURE_MAP: list[tuple[str, str | None, str | None]] = [
|
# Tuple: (host, path_startswith_or_None, path_contains_or_None, label_or_None)
|
||||||
("planner.bincio.org", None, "planner"),
|
_FEATURE_MAP: list[tuple[str, str | None, str | None, str | None]] = [
|
||||||
("wiki.bincio.org", None, "wiki"),
|
("planner.bincio.org", None, None, "planner"),
|
||||||
("activity.bincio.org", "/admin/", None), # exclude admin polling
|
("wiki.bincio.org", None, None, "wiki"),
|
||||||
("activity.bincio.org", "/activity/", "activity"),
|
("activity.bincio.org", "/admin/", None, None), # exclude
|
||||||
("activity.bincio.org", "/segments/", "segments"),
|
("activity.bincio.org", "/activity/", None, "activity"),
|
||||||
("activity.bincio.org", "/stats/", "stats"),
|
("activity.bincio.org", "/segments/", None, "segments"),
|
||||||
("activity.bincio.org", "/explore/", "explore"),
|
("activity.bincio.org", "/stats/", None, "stats"),
|
||||||
("activity.bincio.org", "/ideas/", "ideas"),
|
("activity.bincio.org", "/community/", None, "community"),
|
||||||
("activity.bincio.org", "/u/", "profile"),
|
("activity.bincio.org", "/ideas/", None, "ideas"),
|
||||||
("activity.bincio.org", None, "feed"),
|
# explore lives at /u/{handle}/athlete/explore/ — check before generic /u/
|
||||||
("bincio.org", None, "hub"),
|
("activity.bincio.org", "/u/", "athlete/explore", "explore"),
|
||||||
|
("activity.bincio.org", "/u/", None, "profile"),
|
||||||
|
("activity.bincio.org", None, None, "feed"),
|
||||||
|
("bincio.org", None, None, "hub"),
|
||||||
]
|
]
|
||||||
|
|
||||||
FEATURE_COLORS = {
|
FEATURE_COLORS = {
|
||||||
@@ -91,6 +94,7 @@ FEATURE_COLORS = {
|
|||||||
"wiki": "#a855f7",
|
"wiki": "#a855f7",
|
||||||
"ideas": "#f43f5e",
|
"ideas": "#f43f5e",
|
||||||
"explore": "#34d399",
|
"explore": "#34d399",
|
||||||
|
"community": "#22d3ee",
|
||||||
"profile": "#94a3b8",
|
"profile": "#94a3b8",
|
||||||
"hub": "#64748b",
|
"hub": "#64748b",
|
||||||
"stats": "#e879a0",
|
"stats": "#e879a0",
|
||||||
@@ -105,9 +109,10 @@ def _feature(referer: str) -> str | None:
|
|||||||
path = p.path
|
path = p.path
|
||||||
except Exception:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
for h, prefix, label in _FEATURE_MAP:
|
for h, prefix, contains, label in _FEATURE_MAP:
|
||||||
if host == h:
|
if host == h:
|
||||||
if prefix is None or path.startswith(prefix):
|
if (prefix is None or path.startswith(prefix)) and \
|
||||||
|
(contains is None or contains in path):
|
||||||
return label
|
return label
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user