mirror of
https://github.com/bitwarden/server
synced 2026-01-06 18:43:36 +00:00
[PM-23580] Security Task Metrics (#6164)
* add metrics endpoint for an organization to return completed and total security tasks * refactor metrics fetch to use sql sproc for efficiency rather than having to pull all security task data * add separate response model for security task metrics endpoint * Pascal Case to match existing implementations * refactor org to organization for consistency with other methods * alter security task endpoint: - remove "count" from variable naming - update sproc naming * remove enablement check * replace orgId with organizationId
This commit is contained in:
@@ -24,6 +24,7 @@ public class SecurityTaskController : Controller
|
||||
private readonly IGetTasksForOrganizationQuery _getTasksForOrganizationQuery;
|
||||
private readonly ICreateManyTasksCommand _createManyTasksCommand;
|
||||
private readonly ICreateManyTaskNotificationsCommand _createManyTaskNotificationsCommand;
|
||||
private readonly IGetTaskMetricsForOrganizationQuery _getTaskMetricsForOrganizationQuery;
|
||||
|
||||
public SecurityTaskController(
|
||||
IUserService userService,
|
||||
@@ -31,7 +32,8 @@ public class SecurityTaskController : Controller
|
||||
IMarkTaskAsCompleteCommand markTaskAsCompleteCommand,
|
||||
IGetTasksForOrganizationQuery getTasksForOrganizationQuery,
|
||||
ICreateManyTasksCommand createManyTasksCommand,
|
||||
ICreateManyTaskNotificationsCommand createManyTaskNotificationsCommand)
|
||||
ICreateManyTaskNotificationsCommand createManyTaskNotificationsCommand,
|
||||
IGetTaskMetricsForOrganizationQuery getTaskMetricsForOrganizationQuery)
|
||||
{
|
||||
_userService = userService;
|
||||
_getTaskDetailsForUserQuery = getTaskDetailsForUserQuery;
|
||||
@@ -39,6 +41,7 @@ public class SecurityTaskController : Controller
|
||||
_getTasksForOrganizationQuery = getTasksForOrganizationQuery;
|
||||
_createManyTasksCommand = createManyTasksCommand;
|
||||
_createManyTaskNotificationsCommand = createManyTaskNotificationsCommand;
|
||||
_getTaskMetricsForOrganizationQuery = getTaskMetricsForOrganizationQuery;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -80,6 +83,18 @@ public class SecurityTaskController : Controller
|
||||
return new ListResponseModel<SecurityTasksResponseModel>(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves security task metrics for an organization.
|
||||
/// </summary>
|
||||
/// <param name="organizationId">The organization Id</param>
|
||||
[HttpGet("{organizationId:guid}/metrics")]
|
||||
public async Task<SecurityTaskMetricsResponseModel> GetTaskMetricsForOrganization([FromRoute] Guid organizationId)
|
||||
{
|
||||
var metrics = await _getTaskMetricsForOrganizationQuery.GetTaskMetrics(organizationId);
|
||||
|
||||
return new SecurityTaskMetricsResponseModel(metrics.CompletedTasks, metrics.TotalTasks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulk create security tasks for an organization.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user