refactor(core): Bring active executions into executions controller (no-changelog) (#8371)

This commit is contained in:
Iván Ovejero
2024-01-23 09:48:50 +01:00
committed by GitHub
parent 913c8c6b0c
commit 49b52c4f1d
22 changed files with 544 additions and 331 deletions

View File

@@ -4,10 +4,10 @@ import type { WorkflowStatistics } from '@db/entities/WorkflowStatistics';
import { StatisticsNames } from '@db/entities/WorkflowStatistics';
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
import { WorkflowStatisticsRepository } from '@db/repositories/workflowStatistics.repository';
import { ExecutionRequest } from '@/executions/execution.request';
import type { IWorkflowStatisticsDataLoaded } from '@/Interfaces';
import { Logger } from '@/Logger';
import { NotFoundError } from '@/errors/response-errors/not-found.error';
import { StatisticsRequest } from './workflow-statistics.types';
interface WorkflowStatisticsData<T> {
productionSuccess: T;
@@ -29,7 +29,7 @@ export class WorkflowStatisticsController {
*/
// TODO: move this into a new decorator `@ValidateWorkflowPermission`
@Middleware()
async hasWorkflowAccess(req: ExecutionRequest.Get, res: Response, next: NextFunction) {
async hasWorkflowAccess(req: StatisticsRequest.GetOne, res: Response, next: NextFunction) {
const { user } = req;
const workflowId = req.params.id;
@@ -48,17 +48,17 @@ export class WorkflowStatisticsController {
}
@Get('/:id/counts/')
async getCounts(req: ExecutionRequest.Get): Promise<WorkflowStatisticsData<number>> {
async getCounts(req: StatisticsRequest.GetOne): Promise<WorkflowStatisticsData<number>> {
return await this.getData(req.params.id, 'count', 0);
}
@Get('/:id/times/')
async getTimes(req: ExecutionRequest.Get): Promise<WorkflowStatisticsData<Date | null>> {
async getTimes(req: StatisticsRequest.GetOne): Promise<WorkflowStatisticsData<Date | null>> {
return await this.getData(req.params.id, 'latestEvent', null);
}
@Get('/:id/data-loaded/')
async getDataLoaded(req: ExecutionRequest.Get): Promise<IWorkflowStatisticsDataLoaded> {
async getDataLoaded(req: StatisticsRequest.GetOne): Promise<IWorkflowStatisticsDataLoaded> {
// Get flag
const workflowId = req.params.id;