41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""V141 - Enrich Truth strip agents tooltip with overlap info
|
|
User screenshot showed WTP=950 / paperclip=990 / unified=126 / truth=906
|
|
= discrepancy. Make the truth label self-explanatory with overlap count in tooltip.
|
|
"""
|
|
import sys
|
|
src, dst = sys.argv[1], sys.argv[2]
|
|
with open(src, "r", encoding="utf-8") as f:
|
|
c = f.read()
|
|
|
|
if "V141-AGENTS-TOOLTIP" in c:
|
|
print("ALREADY", file=sys.stderr)
|
|
sys.exit(0)
|
|
|
|
# Modify the setN function call for agents to include a title attribute
|
|
# The current pattern: setN('v139-agents', d.agents?.count_unique);
|
|
# We need to also set title with overlaps
|
|
|
|
old = """ setN('v139-agents', d.agents?.count_unique);"""
|
|
|
|
new = """ setN('v139-agents', d.agents?.count_unique);
|
|
// V141-AGENTS-TOOLTIP: expose dedup context on hover
|
|
const agEl = document.getElementById('v139-agents');
|
|
if (agEl && d.agents) {
|
|
const u = d.agents.count_unique || 0;
|
|
const w = d.agents.count_with_overlaps || 0;
|
|
const bySrc = d.agents.by_source || {};
|
|
const srcList = Object.entries(bySrc).map(([k,v]) => ' ' + k + ': ' + v).join('\\n');
|
|
agEl.title = 'Agents uniques dédupliqués: ' + u + '\\nAvec overlaps bruts: ' + w + '\\nSources:\\n' + srcList + '\\n\\nAutres pages peuvent afficher des chiffres différents (950, 990, 126) car consomment d\\'autres référentiels. Valeur de vérité = 906.';
|
|
agEl.style.cursor = 'help';
|
|
}"""
|
|
|
|
if old not in c:
|
|
print("anchor missing", file=sys.stderr)
|
|
sys.exit(1)
|
|
c = c.replace(old, new, 1)
|
|
|
|
with open(dst, "w", encoding="utf-8") as f:
|
|
f.write(c)
|
|
print(f"OK size={len(c)}", file=sys.stderr)
|