* Get activity summary for a Slack user
(slackUserId: string, options: {
days?: number;
} = {})
| 567 | * Get activity summary for a Slack user |
| 568 | */ |
| 569 | async getActivitySummary(slackUserId: string, options: { |
| 570 | days?: number; |
| 571 | } = {}): Promise<{ |
| 572 | total_messages: number; |
| 573 | total_reactions: number; |
| 574 | total_thread_replies: number; |
| 575 | total_channel_joins: number; |
| 576 | total_activity: number; |
| 577 | active_days: number; |
| 578 | last_activity_at: Date | null; |
| 579 | }> { |
| 580 | const days = options.days ?? 30; |
| 581 | |
| 582 | const result = await query<{ |
| 583 | total_messages: string; |
| 584 | total_reactions: string; |
| 585 | total_thread_replies: string; |
| 586 | total_channel_joins: string; |
| 587 | total_activity: string; |
| 588 | active_days: string; |
| 589 | }>( |
| 590 | `SELECT |
| 591 | COALESCE(SUM(message_count), 0)::text as total_messages, |
| 592 | COALESCE(SUM(reaction_count), 0)::text as total_reactions, |
| 593 | COALESCE(SUM(thread_reply_count), 0)::text as total_thread_replies, |
| 594 | COALESCE(SUM(channel_join_count), 0)::text as total_channel_joins, |
| 595 | COALESCE(SUM(total_activity), 0)::text as total_activity, |
| 596 | COUNT(*)::text as active_days |
| 597 | FROM slack_activity_daily |
| 598 | WHERE slack_user_id = $1 |
| 599 | AND activity_date >= CURRENT_DATE - $2::integer`, |
| 600 | [slackUserId, days] |
| 601 | ); |
| 602 | |
| 603 | const mapping = await this.getBySlackUserId(slackUserId); |
| 604 | |
| 605 | const row = result.rows[0]; |
| 606 | return { |
| 607 | total_messages: parseInt(row.total_messages, 10), |
| 608 | total_reactions: parseInt(row.total_reactions, 10), |
| 609 | total_thread_replies: parseInt(row.total_thread_replies, 10), |
| 610 | total_channel_joins: parseInt(row.total_channel_joins, 10), |
| 611 | total_activity: parseInt(row.total_activity, 10), |
| 612 | active_days: parseInt(row.active_days, 10), |
| 613 | last_activity_at: mapping?.last_slack_activity_at || null, |
| 614 | }; |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * Get organization activity summary from Slack (aggregates all mapped users) |
no test coverage detected