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