| | | 1 | | using Elsa.Authorization; |
| | | 2 | | using Elsa.Abstractions; |
| | | 3 | | using Elsa.Workflows.Runtime; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Api.Endpoints.ActivityExecutions.Report; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Gets a report for the specified set of activities that includes number of executions, split by completed and non-com |
| | | 10 | | /// </summary> |
| | | 11 | | [PublicAPI] |
| | | 12 | | internal class Report : ElsaEndpoint<Request, Response> |
| | | 13 | | { |
| | | 14 | | private readonly IActivityExecutionStore _store; |
| | | 15 | | private readonly IActivityExecutionStatsService _activityExecutionStatsService; |
| | | 16 | | |
| | | 17 | | /// <inheritdoc /> |
| | 3 | 18 | | public Report(IActivityExecutionStore store, IActivityExecutionStatsService activityExecutionStatsService) |
| | | 19 | | { |
| | 3 | 20 | | _store = store; |
| | 3 | 21 | | _activityExecutionStatsService = activityExecutionStatsService; |
| | 3 | 22 | | } |
| | | 23 | | |
| | | 24 | | /// <inheritdoc /> |
| | | 25 | | public override void Configure() |
| | | 26 | | { |
| | 3 | 27 | | Post("/activity-executions/report"); |
| | 3 | 28 | | RequirePermission(Elsa.Workflows.Api.Permissions.WorkflowPermissions.ActivityExecutions, CoreVerbs.View); |
| | 3 | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <inheritdoc /> |
| | | 32 | | public override async Task<Response> ExecuteAsync(Request request, CancellationToken cancellationToken) |
| | | 33 | | { |
| | 0 | 34 | | var stats = (await _activityExecutionStatsService.GetStatsAsync(request.WorkflowInstanceId, request.ActivityNode |
| | | 35 | | |
| | 0 | 36 | | return new() |
| | 0 | 37 | | { |
| | 0 | 38 | | Stats = stats |
| | 0 | 39 | | }; |
| | 0 | 40 | | } |
| | | 41 | | } |