KamoCRM

One query for an organization's whole reporting graph

Featurekamo-shared-library
Shipped
September 23, 2026 at 4:04 AM UTC
Author
Kamo
Commit
b1e20fc

findMemberAndManagerIds returns every (memberId, managerId) edge in one organization, for Hosted Computers' ACCESS_SUBORDINATE_COMPUTERS right — which reaches the whole subtree below a member rather than only their direct reports. The alternative is findDirectReportMemberIds walked level by level, which is a query per level on a path the nav menu hits on every page load, and the depth is a property of the customer's org chart rather than anything this code controls. Returns the EDGES rather than a resolved subtree, because the traversal has to guard against a cycle: managerId is a free-form reference on a member's own profile, not a validated tree, so A reporting to B while B reports to A is one mis-click or one reorganisation away and a recursive query would not return. The caller walks these breadth-first over a visited set. Filters mirror findDirectReportMemberIds exactly, including the explicit LEFT JOIN on tm.user — an implicit path join is an INNER join in JPQL and would silently drop every report whose user row is missing, which that method's own comment records. Validated by LibraryQueryParseTest, which translates every @Query in the library against the real entity mapping. That matters here: Spring Data validates an annotated query when it builds the repository bean, so a bad path compiles, passes CI, ships, and then stops the consuming service from starting at all.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing