mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
[EC-247] Add columns to provider portal clients table (#2136)
* Added migration script to alter ProviderOrganizationOrganizationDetailsView to add new columns UserCount, Seats and Plan * Modified EF query ProviderOrganizationOrganizationDetailsReadByProviderIdQuery * Modified model to output new view columns * Updated view to count only active users * Filtering the organization user count by only confirmed users
This commit is contained in:
parent
d1db4d31cb
commit
169a4381dd
@ -38,6 +38,9 @@ namespace Bit.Api.Models.Response.Providers
|
|||||||
Settings = providerOrganization.Settings;
|
Settings = providerOrganization.Settings;
|
||||||
CreationDate = providerOrganization.CreationDate;
|
CreationDate = providerOrganization.CreationDate;
|
||||||
RevisionDate = providerOrganization.RevisionDate;
|
RevisionDate = providerOrganization.RevisionDate;
|
||||||
|
UserCount = providerOrganization.UserCount;
|
||||||
|
Seats = providerOrganization.Seats;
|
||||||
|
Plan = providerOrganization.Plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
@ -47,6 +50,9 @@ namespace Bit.Api.Models.Response.Providers
|
|||||||
public string Settings { get; set; }
|
public string Settings { get; set; }
|
||||||
public DateTime CreationDate { get; set; }
|
public DateTime CreationDate { get; set; }
|
||||||
public DateTime RevisionDate { get; set; }
|
public DateTime RevisionDate { get; set; }
|
||||||
|
public int UserCount { get; set; }
|
||||||
|
public int? Seats { get; set; }
|
||||||
|
public string Plan { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ProviderOrganizationOrganizationDetailsResponseModel : ProviderOrganizationResponseModel
|
public class ProviderOrganizationOrganizationDetailsResponseModel : ProviderOrganizationResponseModel
|
||||||
|
@ -10,5 +10,8 @@
|
|||||||
public string Settings { get; set; }
|
public string Settings { get; set; }
|
||||||
public DateTime CreationDate { get; set; }
|
public DateTime CreationDate { get; set; }
|
||||||
public DateTime RevisionDate { get; set; }
|
public DateTime RevisionDate { get; set; }
|
||||||
|
public int UserCount { get; set; }
|
||||||
|
public int? Seats { get; set; }
|
||||||
|
public string Plan { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ namespace Bit.Infrastructure.EntityFramework.Repositories.Queries
|
|||||||
var query = from po in dbContext.ProviderOrganizations
|
var query = from po in dbContext.ProviderOrganizations
|
||||||
join o in dbContext.Organizations
|
join o in dbContext.Organizations
|
||||||
on po.OrganizationId equals o.Id
|
on po.OrganizationId equals o.Id
|
||||||
|
join ou in dbContext.OrganizationUsers
|
||||||
|
on po.OrganizationId equals ou.OrganizationId
|
||||||
where po.ProviderId == _providerId
|
where po.ProviderId == _providerId
|
||||||
select new { po, o };
|
select new { po, o };
|
||||||
return query.Select(x => new ProviderOrganizationOrganizationDetails()
|
return query.Select(x => new ProviderOrganizationOrganizationDetails()
|
||||||
@ -27,6 +29,9 @@ namespace Bit.Infrastructure.EntityFramework.Repositories.Queries
|
|||||||
Settings = x.po.Settings,
|
Settings = x.po.Settings,
|
||||||
CreationDate = x.po.CreationDate,
|
CreationDate = x.po.CreationDate,
|
||||||
RevisionDate = x.po.RevisionDate,
|
RevisionDate = x.po.RevisionDate,
|
||||||
|
UserCount = x.o.OrganizationUsers.Count(ou => ou.Status == Core.Enums.OrganizationUserStatusType.Confirmed),
|
||||||
|
Seats = x.o.Seats,
|
||||||
|
Plan = x.o.Plan
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
-- Add columns 'UserCount', 'Seats' and 'Plan'
|
||||||
|
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,
|
||||||
|
O.[Seats],
|
||||||
|
O.[Plan]
|
||||||
|
FROM
|
||||||
|
[dbo].[ProviderOrganization] PO
|
||||||
|
LEFT JOIN
|
||||||
|
[dbo].[Organization] O ON O.[Id] = PO.[OrganizationId]
|
||||||
|
GO
|
Loading…
Reference in New Issue
Block a user