Skip to content

Commit ed486f9

Browse files
committed
fix(automations): update check new feed script
1 parent 314779a commit ed486f9

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

automations/check_new_feed.py

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ def get(cls, name: str) -> "NetworkConfig":
2929
ISSUES_FILE: Final[Path] = Path("issues.md")
3030
MAX_MARKET_CAP_RANK: Final[int] = 100
3131
MIN_USD_VOLUME: Final[int] = 100_000_000
32+
HEADER_CHAR_LIMIT: Final[int] = 140
3233
GITHUB_NEUTRAL_EXIT: Final[int] = 78
33-
HEADER_TEMPLATE: Final[str] = """---
34-
title: "[auto_req]: Potential New Feeds"
35-
assignees:
36-
- dineshpinto
37-
labels:
38-
- enhancement
39-
---
40-
"""
4134
_VOLUME_RE = re.compile(r"^\$?\s*([\d,]+(?:\.\d{1,2})?)$")
4235
REGISTRY_ADDRESS: Final[str] = "0xaD67FE66660Fb8dFE9d6b1b4240d8650e30F6019"
4336
NETWORKS: list[NetworkConfig] = [
@@ -145,12 +138,45 @@ def parse_volume(vol_str: str) -> int:
145138
return int(float(num))
146139

147140

141+
def _build_header(coins: list[dict[str, Any]]) -> str:
142+
"""
143+
Build the YAML front-matter with a title that lists coin names.
144+
"""
145+
base = "[auto_req]: Potential New Feeds - "
146+
symbols_all = [c.get("symbol", "N/A") for c in coins]
147+
148+
# Accumulate names until a ~140-char title budget is hit; then append "+N more".
149+
acc: list[str] = []
150+
for symbol in symbols_all:
151+
candidate = ", ".join([*acc, symbol])
152+
if len(base + candidate) <= HEADER_CHAR_LIMIT:
153+
acc.append(symbol)
154+
else:
155+
break
156+
if len(acc) < len(symbols_all):
157+
title_symbols = f"{', '.join(acc)} (+{len(symbols_all) - len(acc)} more)"
158+
else:
159+
title_symbols = ", ".join(acc)
160+
161+
safe_title_symbols = title_symbols.replace('"', r"\"")
162+
163+
return (
164+
f"---\n"
165+
f'title: "{base}{safe_title_symbols}"\n'
166+
f"assignees:\n"
167+
f" - dineshpinto\n"
168+
f"labels:\n"
169+
f" - enhancement\n"
170+
f"---\n"
171+
)
172+
173+
148174
def write_issue(coins: list[dict[str, Any]]) -> None:
149175
lines = [
150-
"Coins matching [FIP.08](https://proposals.flare.network/FIP/FIP_8.html) criteria:\n"
176+
"Feeds potentially matching [FIP.08](https://proposals.flare.network/FIP/FIP_8.html) criteria:\n"
151177
]
152178
lines += [f"## {c.get('name', 'N/A')}\n{prettify_coin(c)}\n" for c in coins]
153-
content = HEADER_TEMPLATE + "\n".join(lines)
179+
content = _build_header(coins) + "\n".join(lines)
154180
tmp = ISSUES_FILE.with_suffix(".tmp")
155181
tmp.write_text(
156182
content if content.endswith("\n") else content + "\n", encoding="utf-8"

0 commit comments

Comments
 (0)