Merge pull request #509 from automatisch/fix-scheduler

fix: provide step.parameters to Scheduler triggers
This commit is contained in:
Ömer Faruk Aydın
2022-09-18 17:06:09 +03:00
committed by GitHub
7 changed files with 16 additions and 18 deletions

View File

@@ -1,18 +1,15 @@
import Triggers from './triggers';
import {
IService,
IApp,
IJSONObject,
IConnection,
IFlow,
IStep,
} from '@automatisch/types';
export default class Scheduler implements IService {
triggers: Triggers;
constructor(
appData: IApp,
connectionData: IJSONObject,
parameters: IJSONObject
) {
this.triggers = new Triggers(connectionData, parameters);
constructor(connection: IConnection, flow: IFlow, step: IStep) {
this.triggers = new Triggers(step.parameters);
}
}

View File

@@ -1,4 +1,4 @@
import { IJSONObject } from '@automatisch/types';
import { IStep } from '@automatisch/types';
import EveryHour from './triggers/every-hour';
import EveryDay from './triggers/every-day';
import EveryWeek from './triggers/every-week';
@@ -10,7 +10,7 @@ export default class Triggers {
everyWeek: EveryWeek;
everyMonth: EveryMonth;
constructor(connectionData: IJSONObject, parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
this.everyHour = new EveryHour(parameters);
this.everyDay = new EveryDay(parameters);
this.everyWeek = new EveryWeek(parameters);

View File

@@ -1,12 +1,12 @@
import { DateTime } from 'luxon';
import type { IJSONObject, IJSONValue, ITrigger } from '@automatisch/types';
import type { IStep, IJSONValue, ITrigger } from '@automatisch/types';
import { cronTimes, getNextCronDateTime, getDateTimeObjectRepresentation } from '../utils';
export default class EveryDay implements ITrigger {
triggersOnWeekend?: boolean;
hour?: number;
constructor(parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
if (parameters.triggersOnWeekend) {
this.triggersOnWeekend = parameters.triggersOnWeekend as boolean;
}

View File

@@ -1,11 +1,11 @@
import { DateTime } from 'luxon';
import type { IJSONObject, IJSONValue, ITrigger } from '@automatisch/types';
import type { IStep, IJSONValue, ITrigger } from '@automatisch/types';
import { cronTimes, getNextCronDateTime, getDateTimeObjectRepresentation } from '../utils';
export default class EveryHour implements ITrigger {
triggersOnWeekend?: boolean | string;
constructor(parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
if (parameters.triggersOnWeekend) {
this.triggersOnWeekend = parameters.triggersOnWeekend as string;
}

View File

@@ -1,12 +1,12 @@
import { DateTime } from 'luxon';
import type { IJSONObject, IJSONValue, ITrigger } from '@automatisch/types';
import type { IStep, IJSONValue, ITrigger } from '@automatisch/types';
import { cronTimes, getNextCronDateTime, getDateTimeObjectRepresentation } from '../utils';
export default class EveryMonth implements ITrigger {
day?: number;
hour?: number;
constructor(parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
if (parameters.day) {
this.day = parameters.day as number;
}

View File

@@ -1,12 +1,12 @@
import { DateTime } from 'luxon';
import type { IJSONObject, IJSONValue, ITrigger } from '@automatisch/types';
import type { IStep, IJSONValue, ITrigger } from '@automatisch/types';
import { cronTimes, getNextCronDateTime, getDateTimeObjectRepresentation } from '../utils';
export default class EveryWeek implements ITrigger {
weekday?: number;
hour?: number;
constructor(parameters: IJSONObject) {
constructor(parameters: IStep["parameters"]) {
if (parameters.weekday) {
this.weekday = parameters.weekday as number;
}

View File

@@ -34,6 +34,7 @@ const getFlows = async (_parent: unknown, params: Params, context: Context) => {
}
})
.groupBy('flows.id')
.orderBy('active', 'desc')
.orderBy('updated_at', 'desc');
return paginate(flowsQuery, params.limit, params.offset);