Skip to content

Commit

Permalink
Change the return type of getCurrentStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
banderror committed Nov 1, 2021
1 parent f4b16f4 commit 582efaa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export class EventLogAdapter implements IRuleExecutionLogClient {
});
}

public getCurrentStatus(args: GetCurrentStatusArgs): Promise<IRuleStatusSOAttributes> {
public getCurrentStatus(
args: GetCurrentStatusArgs
): Promise<IRuleStatusSOAttributes | undefined> {
return this.savedObjectsAdapter.getCurrentStatus(args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export class RuleExecutionLogClient implements IRuleExecutionLogClient {
return this.client.getLastFailures(args);
}

public getCurrentStatus(args: GetCurrentStatusArgs): Promise<IRuleStatusSOAttributes> {
public getCurrentStatus(
args: GetCurrentStatusArgs
): Promise<IRuleStatusSOAttributes | undefined> {
return this.client.getCurrentStatus(args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ export class SavedObjectsAdapter implements IRuleExecutionLogClient {
return result.map((so) => so.attributes).slice(1);
}

public async getCurrentStatus(args: GetCurrentStatusArgs): Promise<IRuleStatusSOAttributes> {
public async getCurrentStatus(
args: GetCurrentStatusArgs
): Promise<IRuleStatusSOAttributes | undefined> {
const result = await this.findRuleStatusSavedObjects(args.ruleId, 1);
return result[0].attributes;
const currentStatusSavedObject = result[0];
return currentStatusSavedObject ? currentStatusSavedObject.attributes : undefined;
}

public async getCurrentStatusBulk(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface IRuleExecutionLogClient {
findBulk(args: FindBulkExecutionLogArgs): Promise<FindBulkExecutionLogResponse>;

getLastFailures(args: GetLastFailuresArgs): Promise<IRuleStatusSOAttributes[]>;
getCurrentStatus(args: GetCurrentStatusArgs): Promise<IRuleStatusSOAttributes>;
getCurrentStatus(args: GetCurrentStatusArgs): Promise<IRuleStatusSOAttributes | undefined>;
getCurrentStatusBulk(args: GetCurrentStatusBulkArgs): Promise<GetCurrentStatusBulkResult>;

deleteCurrentStatus(ruleId: string): Promise<void>;
Expand Down

0 comments on commit 582efaa

Please sign in to comment.