Skip to content

Commit

Permalink
feat(Daily Report): remove hints
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewuu committed Jan 19, 2025
1 parent 844bbf0 commit bd78e23
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 117 deletions.
102 changes: 0 additions & 102 deletions src/lib/daily-report/get-daily-report-homie-hints-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,102 +0,0 @@
import { ChatPostMessageArguments } from '@slack/web-api/dist/methods'
import { sample } from 'lodash'

interface GetDailyReportHomieHintsBlocks {
pendingTasks: Array<{ name: string; html_url: string }>
pullRequests: Array<{
title: string
contributor_id: number
html_url: string
}>
contributors: Array<{
username: string
ext_slack_member_id: string | null
id: number
}>
extSlackBotUserId: string
}

export async function getDailyReportHomieHintsBlocks(
params: GetDailyReportHomieHintsBlocks,
) {
const { pendingTasks, contributors, pullRequests, extSlackBotUserId } = params

const hintsBlocks: ChatPostMessageArguments['blocks'] = [
{
type: 'header',
text: {
type: 'plain_text',
text: 'Homie ⚡️',
emoji: true,
},
},
{
type: 'section',
text: {
type: 'plain_text',
text: 'Do more with Homie, try out some of these commands:',
},
},
]

const hints: string[] = []

// Explain PR
const randomPullRequest = sample(pullRequests)
if (randomPullRequest) {
hints.push(`<@${extSlackBotUserId}> explain PR ${randomPullRequest.title}`)
}

// Assign a task
const contributorToAssign = sample(contributors)
const taskToAssign = sample(pendingTasks)
if (
contributorToAssign &&
contributorToAssign.ext_slack_member_id &&
taskToAssign
) {
hints.push(
`<@${extSlackBotUserId}> assign ${taskToAssign.name} to <@${contributorToAssign.ext_slack_member_id}>`,
)
}

// Generate changelog
hints.push(`<@${extSlackBotUserId}> generate changelog for PRs above.`)

// Turn PR into blogpost
const blogPostPR = sample(pullRequests)
if (blogPostPR) {
hints.push(
`<@${extSlackBotUserId}> turn PR ${blogPostPR.title} into a blog post.`,
)
}

// Remember slack thread
hints.push(`<@${extSlackBotUserId}> remember this conversation.`)

// Ask if a bug was fixed
hints.push(`<@${extSlackBotUserId}> did we fix <some bug>?`)

// Find all PRs related to some topic
hints.push(`<@${extSlackBotUserId}> find all PRs for <some topic>`)

for (const hint of hints) {
hintsBlocks.push({
type: 'section',
text: {
type: 'mrkdwn',
text: `• ${hint}`,
},
})
}

hintsBlocks.push({
type: 'section',
text: {
type: 'mrkdwn',
text: 'Check out the <https://homie.gg/docs/getting-started|docs> for more features.',
},
})

return hintsBlocks
}
15 changes: 0 additions & 15 deletions src/queue/jobs/send-organization-daily-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { getAssignedTasks } from '@/lib/daily-report/get-assigned-tasks'
import { getDailyReportSummaryBlocks } from '@/lib/daily-report/get-daily-report-summary-blocks'
import { getDailyReportPullRequestBlocks } from '@/lib/daily-report/get-daily-report-pull-request-blocks'
import { getDailyReportTaskBlocks } from '@/lib/daily-report/get-daily-report-task-blocks'
import { getDailyReportHomieHintsBlocks } from '@/lib/daily-report/get-daily-report-homie-hints-blocks'
import { subHours } from 'date-fns'
import { logger } from '@/lib/log/logger'
import { getOrganizationLogData } from '@/lib/organization/get-organization-log-data'
Expand Down Expand Up @@ -263,20 +262,6 @@ export const sendOrganizationDailyReport = createJob({
num_assigned_tasks: Object.values(assignedTasks).length,
})
}

// Homie hints
await slackClient.post<{
ts: string
}>('chat.postMessage', {
channel: organization.ext_slack_webhook_channel_id,
thread_ts: res.ts,
blocks: await getDailyReportHomieHintsBlocks({
pendingTasks,
pullRequests,
contributors: Object.values(contributors),
extSlackBotUserId: organization.ext_slack_bot_user_id,
}),
})
}
},
})

0 comments on commit bd78e23

Please sign in to comment.