Add state to MCP profile and refactor contract filter

Add the profile state attribute (ACTIVE/INACTIVE) to the MCP
Profile schema so listUsers and getUser tools expose it, and
add a state filter to listUsers.

Rename excludeContractEnded to contractEnded across the entire
stack (MCP, GraphQL, CLI, frontend). The new boolean is two-way:
true returns only users with ended contracts, false returns only
users with active or no contract, and null returns all.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-24 11:45:52 +04:00
parent b7a28573f7
commit 272f63828f
16 changed files with 43 additions and 23 deletions

View File

@@ -25,7 +25,7 @@ type (
MembershipProfileFilter struct {
withMembership *bool
withTrustCenterAccess *bool
excludeContractEnded *bool
contractEnded *bool
currentDate time.Time
email *mail.Addr
userName *string
@@ -35,10 +35,10 @@ type (
}
)
func NewMembershipProfileFilter(excludeContractEnded *bool) *MembershipProfileFilter {
func NewMembershipProfileFilter(contractEnded *bool) *MembershipProfileFilter {
return &MembershipProfileFilter{
excludeContractEnded: excludeContractEnded,
currentDate: time.Now(),
contractEnded: contractEnded,
currentDate: time.Now(),
}
}
@@ -96,7 +96,7 @@ func (f *MembershipProfileFilter) SQLArguments() pgx.StrictNamedArgs {
"filter_external_id": f.externalID,
"with_membership": f.withMembership,
"with_trust_center_access": f.withTrustCenterAccess,
"exclude_contract_ended": f.excludeContractEnded,
"contract_ended": f.contractEnded,
"current_date": f.currentDate,
"filter_state": f.state,
"filter_source": f.source,
@@ -132,7 +132,9 @@ AND (
)
AND (
CASE
WHEN @exclude_contract_ended::boolean IS NOT NULL AND @exclude_contract_ended::boolean = true THEN
WHEN @contract_ended::boolean IS NOT NULL AND @contract_ended::boolean = true THEN
(p.contract_end_date IS NOT NULL AND p.contract_end_date < @current_date::date)
WHEN @contract_ended::boolean IS NOT NULL AND @contract_ended::boolean = false THEN
(p.contract_end_date IS NULL OR p.contract_end_date >= @current_date::date)
ELSE TRUE
END