mirror of
https://github.com/bitwarden/server.git
synced 2024-12-23 17:07:42 +01:00
[AC-2805] Add AssignedSeats
to ProviderOrganizationOrganizationDetailsView
(#4446)
* Add 'AssignedSeats' to ProviderOrganizationOrganizationDetailsView * Add newline * Thomas' feedback
This commit is contained in:
parent
ef44def88b
commit
07d37b1b41
@ -42,6 +42,8 @@ public class ProviderOrganizationResponseModel : ResponseModel
|
||||
RevisionDate = providerOrganization.RevisionDate;
|
||||
UserCount = providerOrganization.UserCount;
|
||||
Seats = providerOrganization.Seats;
|
||||
OccupiedSeats = providerOrganization.OccupiedSeats;
|
||||
RemainingSeats = providerOrganization.Seats - providerOrganization.OccupiedSeats;
|
||||
Plan = providerOrganization.Plan;
|
||||
}
|
||||
|
||||
@ -54,6 +56,8 @@ public class ProviderOrganizationResponseModel : ResponseModel
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public int UserCount { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public int? OccupiedSeats { get; set; }
|
||||
public int? RemainingSeats { get; set; }
|
||||
public string Plan { get; set; }
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class ProviderEventService(
|
||||
ClientName = client.OrganizationName,
|
||||
PlanName = client.Plan,
|
||||
AssignedSeats = client.Seats ?? 0,
|
||||
UsedSeats = client.UserCount,
|
||||
UsedSeats = client.OccupiedSeats ?? 0,
|
||||
Total = client.Plan == enterprisePlan.Name
|
||||
? (client.Seats ?? 0) * discountedEnterpriseSeatPrice
|
||||
: (client.Seats ?? 0) * discountedTeamsSeatPrice
|
||||
|
@ -20,6 +20,7 @@ public class ProviderOrganizationOrganizationDetails
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public int UserCount { get; set; }
|
||||
public int? OccupiedSeats { get; set; }
|
||||
public int? Seats { get; set; }
|
||||
public string Plan { get; set; }
|
||||
public OrganizationStatusType Status { get; set; }
|
||||
|
@ -32,6 +32,7 @@ public class ProviderOrganizationOrganizationDetailsReadByProviderIdQuery : IQue
|
||||
CreationDate = x.po.CreationDate,
|
||||
RevisionDate = x.po.RevisionDate,
|
||||
UserCount = x.o.OrganizationUsers.Count(ou => ou.Status == Core.Enums.OrganizationUserStatusType.Confirmed),
|
||||
OccupiedSeats = x.o.OrganizationUsers.Count(ou => ou.Status >= 0),
|
||||
Seats = x.o.Seats,
|
||||
Plan = x.o.Plan,
|
||||
Status = x.o.Status
|
||||
|
@ -10,6 +10,7 @@ SELECT
|
||||
PO.[CreationDate],
|
||||
PO.[RevisionDate],
|
||||
(SELECT COUNT(1) FROM [dbo].[OrganizationUser] OU WHERE OU.OrganizationId = PO.OrganizationId AND OU.Status = 2) UserCount,
|
||||
(SELECT COUNT(1) FROM [dbo].[OrganizationUser] OU WHERE OU.OrganizationId = PO.OrganizationId AND OU.Status >= 0) OccupiedSeats,
|
||||
O.[Seats],
|
||||
O.[Plan],
|
||||
O.[Status]
|
||||
|
@ -176,7 +176,7 @@ public class ProviderEventServiceTests
|
||||
OrganizationName = "Client 1",
|
||||
Plan = "Teams (Monthly)",
|
||||
Seats = 50,
|
||||
UserCount = 30,
|
||||
OccupiedSeats = 30,
|
||||
Status = OrganizationStatusType.Managed
|
||||
},
|
||||
new ()
|
||||
@ -184,7 +184,7 @@ public class ProviderEventServiceTests
|
||||
OrganizationName = "Client 2",
|
||||
Plan = "Enterprise (Monthly)",
|
||||
Seats = 50,
|
||||
UserCount = 30,
|
||||
OccupiedSeats = 30,
|
||||
Status = OrganizationStatusType.Managed
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,22 @@
|
||||
-- Add column 'AssignedSeats'
|
||||
CREATE OR AlTER VIEW [dbo].[ProviderOrganizationOrganizationDetailsView]
|
||||
AS
|
||||
SELECT
|
||||
PO.[Id],
|
||||
PO.[ProviderId],
|
||||
PO.[OrganizationId],
|
||||
O.[Name] OrganizationName,
|
||||
PO.[Key],
|
||||
PO.[Settings],
|
||||
PO.[CreationDate],
|
||||
PO.[RevisionDate],
|
||||
(SELECT COUNT(1) FROM [dbo].[OrganizationUser] OU WHERE OU.OrganizationId = PO.OrganizationId AND OU.Status = 2) UserCount,
|
||||
(SELECT COUNT(1) FROM [dbo].[OrganizationUser] OU WHERE OU.OrganizationId = PO.OrganizationId AND OU.Status >= 0) OccupiedSeats,
|
||||
O.[Seats],
|
||||
O.[Plan],
|
||||
O.[Status]
|
||||
FROM
|
||||
[dbo].[ProviderOrganization] PO
|
||||
LEFT JOIN
|
||||
[dbo].[Organization] O ON O.[Id] = PO.[OrganizationId]
|
||||
GO
|
Loading…
Reference in New Issue
Block a user