diff --git a/prisma/migrations/20241028225101_add_outreach_category/migration.sql b/prisma/migrations/20241028225101_add_outreach_category/migration.sql new file mode 100644 index 0000000..da0eda9 --- /dev/null +++ b/prisma/migrations/20241028225101_add_outreach_category/migration.sql @@ -0,0 +1,2 @@ +-- AlterEnum +ALTER TYPE "enum_HourLogs_type" ADD VALUE 'outreach'; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index f9755ef..f50151a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -192,6 +192,7 @@ enum enum_HourLogs_type { external summer event + outreach } enum enum_MeetingAttendances_state { diff --git a/src/lib/hour_operations.ts b/src/lib/hour_operations.ts index 37b534f..ce6097a 100644 --- a/src/lib/hour_operations.ts +++ b/src/lib/hour_operations.ts @@ -59,15 +59,15 @@ export async function calculateHours(user: Prisma.MemberWhereUniqueInput) { } user.email = member.email } - const sums = await prisma.hourLog.groupBy({ by: 'type', _sum: { duration: true }, where: { state: 'complete', member_id: user.email, time_out: { gte: season_start_date } } }) + const sums = await prisma.hourLog.groupBy({ by: 'type', _sum: { duration: true }, where: { state: 'complete', member_id: user.email, time_in: { gte: season_start_date } } }) const meetingCount = await prisma.meetingAttendanceEntry.count({ where: { member_id: user.email, state: 'present', Meeting: { date: { gte: season_start_date } } } }) - const out: Record = { event: 0, external: 0, lab: 0, summer: 0, total: 0, qualifying: 0, meeting: 0.5 * meetingCount } + const out: Record = { outreach: 0, event: 0, external: 0, lab: 0, summer: 0, total: 0, qualifying: 0, meeting: 0.5 * meetingCount } sums.forEach((sum) => { out[sum.type] = sum._sum.duration!.toNumber() out.total += out[sum.type] }) out.total += out.meeting - out.qualifying = out.lab + out.external + out.meeting + out.qualifying = out.lab + out.external + out.meeting + out.outreach return out } export async function calculateAllHours() { @@ -79,15 +79,14 @@ export async function calculateAllHours() { }) const meetings = await getMeetings() totals.forEach((total) => { - out[total.member_id] ??= { event: 0, external: 0, lab: 0, summer: 0, total: 0, qualifying: 0, meeting: 0 } + out[total.member_id] ??= { outreach: 0, event: 0, external: 0, lab: 0, summer: 0, total: 0, qualifying: 0, meeting: 0 } out[total.member_id][total.type] = total._sum.duration!.toNumber() out[total.member_id].total += out[total.member_id][total.type] - out[total.member_id].qualifying = out[total.member_id].lab + out[total.member_id].external }) Object.keys(out).forEach((member) => { out[member].meeting = meetings[member] * 0.5 out[member].total += out[member].meeting - out[member].qualifying = out[member].lab + out[member].external + out[member].meeting + out[member].qualifying = out[member].lab + out[member].external + out[member].meeting + out[member].outreach }) return out } diff --git a/src/slack/blocks/admin/hour_submission.ts b/src/slack/blocks/admin/hour_submission.ts index ced201e..e0d7190 100644 --- a/src/slack/blocks/admin/hour_submission.ts +++ b/src/slack/blocks/admin/hour_submission.ts @@ -50,9 +50,10 @@ export function getHourSubmissionBlocks(v: HourSubmissionBlocksInput) { Blocks.Actions().elements( Elements.Button().primary().text('Accept').actionId(ActionIDs.ACCEPT).value(v.request_id), Elements.Button().danger().text('Reject').actionId(ActionIDs.REJECT).value(v.request_id), - Elements.Button().text('☀️').actionId(ActionIDs.ACCEPT_SUMMER).value(v.request_id), + // Elements.Button().text('☀️').actionId(ActionIDs.ACCEPT_SUMMER).value(v.request_id), // 7 buttons renders poorly, not used in fall Elements.Button().text('📆').actionId(ActionIDs.ACCEPT_EVENT).value(v.request_id), Elements.Button().text('🔨').actionId(ActionIDs.ACCEPT_LAB).value(v.request_id), + Elements.Button().text('⛳').actionId(ActionIDs.ACCEPT_OUTREACH).value(v.request_id), Elements.Button().text('Accept w/ Message').actionId(ActionIDs.ACCEPT_WITH_MSG).value(v.request_id) ) ) diff --git a/src/slack/blocks/admin/respond.ts b/src/slack/blocks/admin/respond.ts index 65209df..773771f 100644 --- a/src/slack/blocks/admin/respond.ts +++ b/src/slack/blocks/admin/respond.ts @@ -41,7 +41,8 @@ export function getRespondMessageModal( Bits.Option().text('External').value('external'), Bits.Option().text('Summer ☀️').value('summer'), Bits.Option().text('Event').value('event'), - Bits.Option().text('Lab').value('lab') + Bits.Option().text('Lab').value('lab'), + Bits.Option().text('Outreach').value('outreach') ) ) ) diff --git a/src/slack/blocks/app_home.ts b/src/slack/blocks/app_home.ts index 23bc329..3ae9cdc 100644 --- a/src/slack/blocks/app_home.ts +++ b/src/slack/blocks/app_home.ts @@ -13,22 +13,20 @@ export async function getAppHome(user_id: string) { const homeTab = HomeTab() if (config.slack.users.devs.includes(user_id)) { const tasks = getTaskKeys().map((key) => Bits.Option().text(key).value(key)) - homeTab.blocks( - Blocks.Header().text('Dev Dashboard'), - ) - for (let i = 0; i= 50 ? '50+' : hours -} - export async function updateSheet() { const members = await prisma.member.findMany({ orderBy: { full_name: 'asc' }, where: { active: true } }) const certs = await prisma.memberCert.findMany({ orderBy: { cert_id: 'asc' }, include: { Cert: { select: { label: true } } } }) @@ -53,6 +49,7 @@ export async function updateSheet() { 'ExternalHours', 'EventHours', 'SummerHours', + 'OutreachHours', 'QualifyingHours', 'TotalHours', 'WeeklyHours', @@ -76,6 +73,7 @@ export async function updateSheet() { row[columns.ExternalHours] = hours.external row[columns.EventHours] = hours.event row[columns.SummerHours] = hours.summer + row[columns.OutreachHours] = hours.outreach row[columns.QualifyingHours] = hours.qualifying row[columns.TotalHours] = hours.total row[columns.WeeklyHours] = weeklyHours[m.email] ?? 0 diff --git a/src/tasks/index.ts b/src/tasks/index.ts index 9073f86..ca9d77b 100644 --- a/src/tasks/index.ts +++ b/src/tasks/index.ts @@ -67,10 +67,10 @@ export function scheduleTasks() { // Slack is silly and can only handle 5 items in the overflow menu scheduleCronTask(createTaskFunc(promptCheckinMessage), '0 19 * * FRI') - tasks["Sync Sheet"] = scheduleTask(updateSheet, 60 * 5, isProd, 0) - tasks["Sync Slack Members"] = scheduleTask(syncSlackMembers, 60 * 60, isProd, 0) // can be run from the admin members page - tasks["Update profile Certs"] = scheduleTask(updateProfileCerts, 60 * 60 * 24, isProd, 5 * 60) - tasks["Update Profile Departments"] = scheduleTask(updateProfileDepartments, 60 * 60 * 24, isProd, 10 * 60) + tasks['Sync Sheet'] = scheduleTask(updateSheet, 60 * 5, isProd, 0) + tasks['Sync Slack Members'] = scheduleTask(syncSlackMembers, 60 * 60, isProd, 0) // can be run from the admin members page + tasks['Update profile Certs'] = scheduleTask(updateProfileCerts, 60 * 60 * 24, isProd, 5 * 60) + tasks['Update Profile Departments'] = scheduleTask(updateProfileDepartments, 60 * 60 * 24, isProd, 10 * 60) } export async function runTask(key: string) {