nomadro/apps/api/services/hub_svc/geo_cities.py
Eric d971a1f3e6 Lock Hub to China-only cities and document the cn audience gate.
Hard-enable hubCnOnly, drop foreign cities from default seeds/map/coffeechat, and keep intl cities in separate INT L catalogs until globalization reopens.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-29 00:03:11 +08:00

234 lines
5.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Seed cities with approximate lat/lng for map aggregation (no personal GPS)."""
from __future__ import annotations
from typing import Any
# Offline seed mirrored by src/modules/hub/lib/cities.ts
SEED_CITIES: list[dict[str, Any]] = [
{
"id": "dali",
"name": "大理",
"country": "中国",
"emoji": "🏔️",
"vibe": "苍山洱海 · 慢生活",
"members": 520,
"meetupCount": 12,
"costHint": "¥3,000/月起",
"wifiMbps": 50,
"tags": ["热门", "便宜", "山城"],
"hot": True,
"lat": 25.6065,
"lng": 100.2679,
},
{
"id": "chengdu",
"name": "成都",
"country": "中国",
"emoji": "🌶️",
"vibe": "天府之国 · 美食慢节奏",
"members": 680,
"meetupCount": 18,
"costHint": "¥4,500/月起",
"wifiMbps": 80,
"tags": ["热门", "美食", "宜居"],
"hot": True,
"lat": 30.5728,
"lng": 104.0668,
},
{
"id": "hangzhou",
"name": "杭州",
"country": "中国",
"emoji": "🏞️",
"vibe": "西湖 · 互联网重镇",
"members": 560,
"meetupCount": 14,
"costHint": "¥6,000/月起",
"wifiMbps": 100,
"tags": ["热门", "高速网络"],
"hot": True,
"lat": 30.2741,
"lng": 120.1551,
},
{
"id": "kunming",
"name": "昆明",
"country": "中国",
"emoji": "🌸",
"vibe": "四季如春 · 通往东南亚",
"members": 380,
"meetupCount": 8,
"costHint": "¥3,500/月起",
"wifiMbps": 55,
"tags": ["温暖", "便宜"],
"hot": False,
"lat": 25.0389,
"lng": 102.7183,
},
{
"id": "shenzhen",
"name": "深圳",
"country": "中国",
"emoji": "🚀",
"vibe": "科技创新 · 创业友好",
"members": 850,
"meetupCount": 22,
"costHint": "¥8,000/月起",
"wifiMbps": 120,
"tags": ["热门", "高速网络", "一线城市"],
"hot": True,
"lat": 22.5431,
"lng": 114.0579,
},
{
"id": "xiamen",
"name": "厦门",
"country": "中国",
"emoji": "🏝️",
"vibe": "海滨花园 · 鼓浪屿",
"members": 320,
"meetupCount": 7,
"costHint": "¥5,500/月起",
"wifiMbps": 70,
"tags": ["海滨", "温暖"],
"hot": False,
"lat": 24.4798,
"lng": 118.0894,
},
{
"id": "shanghai",
"name": "上海",
"country": "中国",
"emoji": "🌆",
"vibe": "国际大都市 · 文化交汇",
"members": 1200,
"meetupCount": 28,
"costHint": "¥10,000/月起",
"wifiMbps": 110,
"tags": ["一线城市", "热门"],
"hot": True,
"lat": 31.2304,
"lng": 121.4737,
},
{
"id": "lijiang",
"name": "丽江",
"country": "中国",
"emoji": "🏯",
"vibe": "玉龙雪山 · 古城慢旅",
"members": 280,
"meetupCount": 5,
"costHint": "¥3,200/月起",
"wifiMbps": 45,
"tags": ["便宜", "山城"],
"hot": False,
"lat": 26.8721,
"lng": 100.2299,
},
]
# 国际城市(Hub 中文锁期间不进 SEED_CITIES)
SEED_CITIES_INTL: list[dict[str, Any]] = [
{
"id": "chiangmai",
"name": "清迈",
"country": "泰国",
"emoji": "🌿",
"vibe": "Nimman · 游民大本营",
"members": 940,
"meetupCount": 36,
"costHint": "฿18,000/月起",
"wifiMbps": 90,
"tags": ["热门", "友好社区", "高速网络"],
"hot": True,
"lat": 18.7883,
"lng": 98.9853,
},
{
"id": "bali",
"name": "巴厘岛",
"country": "印尼",
"emoji": "🌴",
"vibe": "Canggu · 冲浪与 cowork",
"members": 720,
"meetupCount": 24,
"costHint": "Rp8jt/月起",
"wifiMbps": 60,
"tags": ["海滨", "温暖", "热门"],
"hot": True,
"lat": -8.6478,
"lng": 115.1385,
},
{
"id": "lisbon",
"name": "里斯本",
"country": "葡萄牙",
"emoji": "🌊",
"vibe": "阳光海岸 · 欧洲时区",
"members": 610,
"meetupCount": 16,
"costHint": "€1,200/月起",
"wifiMbps": 100,
"tags": ["海滨", "友好社区"],
"hot": False,
"lat": 38.7223,
"lng": -9.1393,
},
{
"id": "penang",
"name": "槟城",
"country": "马来西亚",
"emoji": "🍜",
"vibe": "美食 · 海风开放工位",
"members": 260,
"meetupCount": 6,
"costHint": "RM2,800/月起",
"wifiMbps": 100,
"tags": ["美食", "便宜"],
"hot": False,
"lat": 5.4141,
"lng": 100.3288,
},
]
_BY_ID = {c["id"]: c for c in SEED_CITIES}
_BY_NAME = {c["name"]: c for c in SEED_CITIES}
def list_seed_cities() -> list[dict[str, Any]]:
return [dict(c) for c in SEED_CITIES]
def get_seed_city(city_id: str) -> dict[str, Any] | None:
c = _BY_ID.get((city_id or "").strip())
return dict(c) if c else None
def resolve_city_id(city: str, city_id: str | None = None) -> str | None:
if city_id and city_id in _BY_ID:
return city_id
name = (city or "").split("·")[0].strip()
hit = _BY_NAME.get(name)
return hit["id"] if hit else None
def city_public(c: dict[str, Any], *, extras: dict[str, Any] | None = None) -> dict[str, Any]:
out = {
"id": c["id"],
"name": c["name"],
"country": c["country"],
"emoji": c.get("emoji", ""),
"vibe": c.get("vibe", ""),
"lat": c["lat"],
"lng": c["lng"],
"memberCount": int(c.get("members") or 0),
"meetupCount": int(c.get("meetupCount") or 0),
"costHint": c.get("costHint", ""),
"wifiMbps": c.get("wifiMbps"),
"tags": list(c.get("tags") or []),
"hot": bool(c.get("hot")),
}
if extras:
out.update(extras)
return out