абузы: free-панели new-api на вкладке (роут /api/panels + грид), CSS вынесен из JS, панельный классификатор даёт freeapi-вес, тесты
This commit is contained in:
20
omni/rank.py
20
omni/rank.py
@@ -2,6 +2,8 @@
|
||||
import re
|
||||
import time
|
||||
|
||||
from .dates import parse_published
|
||||
|
||||
WEIGHT = {"reddit": 1.15, "x": 1.10, "forums": 1.0, "tavily": 1.0, "exa": 1.0,
|
||||
"firecrawl": 0.9, "you": 0.9, "ddg": 0.75, "cards": 0.35, "treg": 0.8}
|
||||
|
||||
@@ -24,20 +26,12 @@ KIND_BONUS = {"tweet": 0.15, "thread": 0.25, "tg_post": 0.2, "card": 0.05, "resu
|
||||
|
||||
|
||||
def _fresh(published):
|
||||
"""published: unix-строка или ISO. Возвращает 0..1."""
|
||||
if not published:
|
||||
return 0.3
|
||||
try:
|
||||
if published.isdigit():
|
||||
ts = int(published)
|
||||
if ts > 10**12:
|
||||
ts //= 1000
|
||||
else:
|
||||
ts = time.mktime(time.strptime(published[:19], "%Y-%m-%dT%H:%M:%S"))
|
||||
days = max(0.0, (time.time() - ts) / 86400)
|
||||
return max(0.0, 1.0 - days / 30.0)
|
||||
except Exception:
|
||||
"""Unix seconds/milliseconds, ISO or RFC 2822. Return freshness in 0..1."""
|
||||
dt = parse_published(published)
|
||||
if dt is None:
|
||||
return 0.3
|
||||
days = max(0.0, (time.time() - dt.timestamp()) / 86400)
|
||||
return max(0.0, 1.0 - days / 30.0)
|
||||
|
||||
|
||||
def score(it):
|
||||
|
||||
Reference in New Issue
Block a user