mirror of
https://github.com/bitwarden/server
synced 2025-12-24 20:23:21 +00:00
[PM-20576] OrganizationReport - Queries and Command (#5983)
This commit is contained in:
@@ -27,4 +27,22 @@ public class OrganizationReportRepository :
|
||||
return Mapper.Map<ICollection<OrganizationReport>>(results);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<OrganizationReport> GetLatestByOrganizationIdAsync(Guid organizationId)
|
||||
{
|
||||
using (var scope = ServiceScopeFactory.CreateScope())
|
||||
{
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
var result = await dbContext.OrganizationReports
|
||||
.Where(p => p.OrganizationId == organizationId)
|
||||
.OrderByDescending(p => p.Date)
|
||||
.Take(1)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (result == null)
|
||||
return default;
|
||||
|
||||
return Mapper.Map<OrganizationReport>(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user