fix: Correct company count in connections map - count unique companies not roles

- API: Count unique company_ids instead of all roles
- Tooltip: Show "X firmami (Y ról)" to distinguish companies from roles
- Bogdan Łaga has 6 unique companies with 9 roles (was showing 9 companies)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-01-11 14:13:56 +01:00
parent c7a46c5ada
commit b29071ab84
2 changed files with 12 additions and 3 deletions

4
app.py
View File

@ -3853,8 +3853,8 @@ def api_connections():
# Person nodes
for p in people:
# Count how many companies this person is connected to
company_count = len([r for r in p.company_roles if r.company and r.company.status == 'active'])
# Count UNIQUE companies this person is connected to (not roles)
company_count = len(set(r.company_id for r in p.company_roles if r.company and r.company.status == 'active'))
nodes.append({
'id': f'person_{p.id}',
'name': f'{p.imiona} {p.nazwisko}',

View File

@ -941,13 +941,22 @@ function initModalGraph(nodes, links) {
if (connected.length > 8) html += `<p style="color: #64748b;">...i ${connected.length - 8} więcej</p>`;
}
} else {
// Get all connections (roles)
const connected = links.filter(l => {
const sId = typeof l.source === 'object' ? l.source.id : l.source;
const tId = typeof l.target === 'object' ? l.target.id : l.target;
return sId === d.id || tId === d.id;
});
html += `<p>Powiązany z ${connected.length} firmami</p>`;
// Count UNIQUE companies (not roles)
const uniqueCompanyIds = new Set();
connected.forEach(l => {
const tId = typeof l.target === 'object' ? l.target.id : l.target;
uniqueCompanyIds.add(tId);
});
const uniqueCompanyCount = uniqueCompanyIds.size;
html += `<p>Powiązany z ${uniqueCompanyCount} firmami (${connected.length} ról)</p>`;
if (connected.length > 0) {
connected.slice(0, 5).forEach(l => {