remove excess info
This commit is contained in:
32
watcher.py
32
watcher.py
@@ -225,9 +225,6 @@ def truncate_text(value: str, limit: int) -> str:
|
||||
if len(text) <= limit:
|
||||
return text
|
||||
return f"{text[: max(0, limit - 1)].rstrip()}…"
|
||||
|
||||
|
||||
def fetch_new_app_page_details(session: requests.Session, app_url: str) -> Dict[str, object]:
|
||||
response = session.get(
|
||||
app_url,
|
||||
timeout=REQUEST_TIMEOUT_SECONDS,
|
||||
@@ -323,35 +320,6 @@ def build_new_app_message(session: requests.Session, app: AppSnapshot) -> str:
|
||||
if app.summary:
|
||||
lines.append(f"Catalog summary: {truncate_text(app.summary, 700)}")
|
||||
|
||||
try:
|
||||
details = fetch_new_app_page_details(session, app.url)
|
||||
except requests.RequestException as exc:
|
||||
logging.warning("Unable to fetch app details for %s: %s", app.url, exc)
|
||||
details = {}
|
||||
|
||||
page_title = str(details.get("page_title", "")) if details else ""
|
||||
if page_title:
|
||||
lines.append(f"Page title: {truncate_text(page_title, 180)}")
|
||||
|
||||
description = str(details.get("description", "")) if details else ""
|
||||
if description:
|
||||
lines.append(f"Description: {truncate_text(description, 1000)}")
|
||||
|
||||
detected_fields = details.get("detected_fields", []) if details else []
|
||||
if isinstance(detected_fields, list):
|
||||
for field in detected_fields[:6]:
|
||||
lines.append(str(field))
|
||||
|
||||
headings = details.get("headings", []) if details else []
|
||||
if isinstance(headings, list) and headings:
|
||||
lines.append(f"Headings: {truncate_text(' | '.join(headings[:6]), 320)}")
|
||||
|
||||
external_links = details.get("external_links", []) if details else []
|
||||
if isinstance(external_links, list) and external_links:
|
||||
lines.append("External links:")
|
||||
for link in external_links[:5]:
|
||||
lines.append(f"- {truncate_text(str(link), 220)}")
|
||||
|
||||
message = "\n".join(lines)
|
||||
if len(message) <= MAX_MESSAGE_LEN:
|
||||
return message
|
||||
|
||||
Reference in New Issue
Block a user