-
Notifications
You must be signed in to change notification settings - Fork 6
Feature: Standup and Prosper Bot Automation #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tylermenezes
merged 8 commits into
codeday:main
from
dotcomaki:feature/create-standup-task
May 22, 2026
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
638354f
Add createStandup activity task
dotcomaki 2ef88b6
Fix createStandup to skip projects with existing standups
dotcomaki 9987159
Remove unnecessary EXCLUDED_SLACK_IDS — students-only filter is suffi…
dotcomaki b066efd
Use per-event standupAndProsperToken via StandupAndProsper client
dotcomaki 6ba1d93
Merge branch 'main' into feature/create-standup-task
tylermenezes 70dd8ca
Refactoring to one event; add bot automatically
tylermenezes 4763f35
Update standup configuration
tylermenezes 258a9c2
Add self as standup admin alongside Tyler
dotcomaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,116 @@ | ||
| import { PrismaClient } from "@prisma/client"; | ||
| import Container from "typedi"; | ||
| import { Context } from '../../context'; | ||
| import { | ||
| SlackEventWithProjects, | ||
| SlackMentorInfo, | ||
| SlackStudentInfo, | ||
| slackEventInfoSelect, | ||
| } from "../../slack"; | ||
| import { makeDebug } from "../../utils"; | ||
|
|
||
| const DEBUG = makeDebug('activities:tasks:createStandup'); | ||
|
|
||
| const STANDUP_API_BASE = 'https://api.standup-and-prosper.com/v1'; | ||
| const EXCLUDED_SLACK_IDS = new Set(['U07ACCWHDSA']); | ||
|
|
||
| const DEFAULT_STANDUP = { | ||
| type: 'SLACK', | ||
| days: ['Monday', 'Wednesday', 'Friday'], | ||
| time: '10:00:00', | ||
| reportTime: '12:00:00', | ||
| timezone: 'America/Los_Angeles', | ||
| schedule: { type: 'WEEKLY' }, | ||
| questions: [ | ||
| { text: 'What did you do since last standup?' }, | ||
| { text: 'What will you do until next standup?' }, | ||
| { text: 'Is anything blocking you?' }, | ||
| ], | ||
| groupBy: 'USER_SINGLE_MESSAGE', | ||
| reportSortOrder: 'DISPLAY_NAME', | ||
| allowEditsAfterCompletion: true, | ||
| asThread: false, | ||
| syncWithChannel: false, | ||
| hideAnnouncements: false, | ||
| }; | ||
|
|
||
| export default async function createStandup({ auth }: Context): Promise<void> { | ||
| const apiKey = process.env.STANDUP_API_KEY; | ||
|
dotcomaki marked this conversation as resolved.
Outdated
dotcomaki marked this conversation as resolved.
Outdated
|
||
| if (!apiKey) throw new Error('STANDUP_API_KEY environment variable is not set'); | ||
|
|
||
| const prisma = Container.get(PrismaClient); | ||
|
|
||
| const existing = await prisma.project.findMany({ | ||
| where: { event: { id: auth.eventId }, standupId: { not: null } }, | ||
| select: { id: true }, | ||
| }); | ||
| const existingStandupIds = new Set(existing.map((p: { id: string }) => p.id)); | ||
|
|
||
| const events = await prisma.event.findMany({ | ||
| where: { | ||
| id: auth.eventId, | ||
| slackWorkspaceAccessToken: { not: null }, | ||
| slackWorkspaceId: { not: null }, | ||
| }, | ||
| select: slackEventInfoSelect, | ||
| }) as SlackEventWithProjects<SlackMentorInfo & SlackStudentInfo>[]; | ||
|
|
||
| for (const event of events) { | ||
| const teamId = event.slackWorkspaceId; | ||
|
|
||
| for (const project of event.projects) { | ||
| if (existingStandupIds.has(project.id)) { | ||
| DEBUG(`Skipping project ${project.id} — standup already exists`); | ||
| continue; | ||
| } | ||
|
|
||
| if (!project.slackChannelId) { | ||
| DEBUG(`Skipping project ${project.id} — no Slack channel`); | ||
| continue; | ||
| } | ||
|
|
||
| const users = project.students | ||
| .filter((s) => s.slackId && !EXCLUDED_SLACK_IDS.has(s.slackId)) | ||
| .map((s) => ({ userId: s.slackId! })); | ||
|
|
||
| if (users.length === 0) { | ||
| DEBUG(`Skipping project ${project.id} — no eligible student Slack IDs`); | ||
| continue; | ||
| } | ||
|
|
||
| const body = { | ||
| ...DEFAULT_STANDUP, | ||
| channel: project.slackChannelId, | ||
| channelId: project.slackChannelId, | ||
| users, | ||
| }; | ||
|
|
||
| try { | ||
| const res = await fetch(`${STANDUP_API_BASE}/teams/${teamId}/standups`, { | ||
| method: 'POST', | ||
| headers: { | ||
| Authorization: `Bearer ${apiKey}`, | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(body), | ||
| }); | ||
|
|
||
| if (!res.ok) { | ||
| const text = await res.text(); | ||
| DEBUG(`Failed for project ${project.id}: ${res.status} ${text}`); | ||
| } else { | ||
| const data = await res.json() as { id?: string }; | ||
|
dotcomaki marked this conversation as resolved.
Outdated
|
||
| if (data.id) { | ||
| await prisma.project.update({ | ||
| where: { id: project.id }, | ||
| data: { standupId: data.id }, | ||
| }); | ||
| } | ||
| DEBUG(`Created standup for project ${project.id} in channel ${project.slackChannelId}`); | ||
| } | ||
| } catch (ex) { | ||
| DEBUG(ex); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.