-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
135 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint-disable no-console */ | ||
|
||
import { | ||
DefineFunction, | ||
Schema, | ||
SlackFunction, | ||
} from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { getStats } from '../../database/getters.ts' | ||
import { getDbAuthArgs } from '../util/db-args.ts' | ||
|
||
export const GetStats = DefineFunction({ | ||
callback_id: 'get_stats', | ||
title: 'Get stats', | ||
description: 'Gets the stats from the database', | ||
source_file: 'functions/get_stats.ts', | ||
input_parameters: { | ||
properties: { | ||
environment: { | ||
type: Schema.types.string, | ||
enum: ['Test', 'Production'], | ||
}, | ||
}, | ||
required: ['environment'], | ||
}, | ||
output_parameters: { | ||
properties: { | ||
stats: { | ||
type: Schema.types.object, | ||
description: 'The stats from the database as JSON', | ||
}, | ||
}, | ||
required: ['stats'], | ||
}, | ||
}) | ||
|
||
export default SlackFunction( | ||
GetStats, | ||
async ({ inputs, env }) => { | ||
const res = await getStats(getDbAuthArgs(env, inputs.environment === 'Test')) | ||
console.log(`Fetched stats ${JSON.stringify(res)}`) | ||
return !res || typeof res === 'string' | ||
? { error: JSON.stringify(res) } | ||
: { outputs: { stats: res } } | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,7 @@ import { | |
} from 'https://deno.land/x/[email protected]/mod.ts' | ||
import GetLocationInfoWorkflow from '../workflows/get_location_info.ts' | ||
|
||
const createDeleteLocationShortcut: Trigger< | ||
typeof GetLocationInfoWorkflow.definition | ||
> = { | ||
const createDeleteLocationShortcut: Trigger<typeof GetLocationInfoWorkflow.definition> = { | ||
type: TriggerTypes.Shortcut, | ||
name: 'Get Location info', | ||
description: 'Get Location info with a uuid', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Trigger } from 'https://deno.land/x/[email protected]/types.ts' | ||
import { | ||
TriggerContextData, | ||
TriggerTypes, | ||
} from 'https://deno.land/x/[email protected]/mod.ts' | ||
import GetStatsInfoWorkflow from '../workflows/get_stats_info.ts' | ||
|
||
const createDeleteLocationShortcut: Trigger<typeof GetStatsInfoWorkflow.definition> = { | ||
type: TriggerTypes.Shortcut, | ||
name: 'Get Stats', | ||
description: 'Get Stats from the database', | ||
workflow: `#/workflows/${GetStatsInfoWorkflow.definition.callback_id}`, | ||
inputs: { | ||
interactivity: { | ||
value: TriggerContextData.Shortcut.interactivity, | ||
}, | ||
}, | ||
} | ||
|
||
export default createDeleteLocationShortcut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
DefineWorkflow, | ||
Schema, | ||
} from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { SendContext } from '../functions/send_context.ts' | ||
import { GetStats } from '../functions/get_stats.ts' | ||
|
||
const GetStatsWorkflow = DefineWorkflow({ | ||
callback_id: 'get_stats_wf', | ||
title: 'Get stats', | ||
description: 'Get stats from the database', | ||
input_parameters: { | ||
properties: { | ||
interactivity: { | ||
type: Schema.slack.types.interactivity, | ||
}, | ||
}, | ||
required: ['interactivity'], | ||
}, | ||
}) | ||
|
||
const statsStep = GetStatsWorkflow.addStep( | ||
GetStats, | ||
{ environment: 'Production' }, | ||
) | ||
|
||
GetStatsWorkflow.addStep( | ||
SendContext, | ||
{ | ||
stats: statsStep.outputs.stats, | ||
environment: 'Production', | ||
reviewer: GetStatsWorkflow.inputs.interactivity.interactor.id, | ||
type: 'stats', | ||
}, | ||
) | ||
|
||
export default GetStatsWorkflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters