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:
parent
c7a46c5ada
commit
b29071ab84
4
app.py
4
app.py
@ -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}',
|
||||
|
||||
@ -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 => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user