1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05: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:
Rui Tomé
2022-07-28 09:31:03 +01:00
committed by GitHub
parent d1db4d31cb
commit 169a4381dd
4 changed files with 34 additions and 0 deletions

View File

@ -38,6 +38,9 @@ namespace Bit.Api.Models.Response.Providers
Settings = providerOrganization.Settings;
CreationDate = providerOrganization.CreationDate;
RevisionDate = providerOrganization.RevisionDate;
UserCount = providerOrganization.UserCount;
Seats = providerOrganization.Seats;
Plan = providerOrganization.Plan;
}
public Guid Id { get; set; }
@ -47,6 +50,9 @@ namespace Bit.Api.Models.Response.Providers
public string Settings { get; set; }
public DateTime CreationDate { 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

View File

@ -10,5 +10,8 @@
public string Settings { get; set; }
public DateTime CreationDate { get; set; }
public DateTime RevisionDate { get; set; }
public int UserCount { get; set; }
public int? Seats { get; set; }
public string Plan { get; set; }
}
}

View File

@ -15,6 +15,8 @@ namespace Bit.Infrastructure.EntityFramework.Repositories.Queries
var query = from po in dbContext.ProviderOrganizations
join o in dbContext.Organizations
on po.OrganizationId equals o.Id
join ou in dbContext.OrganizationUsers
on po.OrganizationId equals ou.OrganizationId
where po.ProviderId == _providerId
select new { po, o };
return query.Select(x => new ProviderOrganizationOrganizationDetails()
@ -27,6 +29,9 @@ namespace Bit.Infrastructure.EntityFramework.Repositories.Queries
Settings = x.po.Settings,
CreationDate = x.po.CreationDate,
RevisionDate = x.po.RevisionDate,
UserCount = x.o.OrganizationUsers.Count(ou => ou.Status == Core.Enums.OrganizationUserStatusType.Confirmed),
Seats = x.o.Seats,
Plan = x.o.Plan
});
}
}