Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/activity-user-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

Display user names instead of Slack IDs in proactive outreach history
8 changes: 5 additions & 3 deletions server/public/admin-outreach.html
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,12 @@ <h2 id="variant-modal-title">New Variant</h2>

function renderHistory() {
const tbody = document.getElementById('history-body');
tbody.innerHTML = history.map(item => `
tbody.innerHTML = history.map(item => {
const userName = item.slack_display_name || item.slack_real_name || item.slack_user_id;
return `
<tr>
<td>${formatDate(item.sent_at)}</td>
<td>${escapeHtml(item.slack_user_id)}</td>
<td>${escapeHtml(userName)}</td>
<td><span class="badge badge-info">${item.outreach_type}</span></td>
<td>${item.tone ? `${item.tone} / ${item.approach}` : '—'}</td>
<td>
Expand All @@ -680,7 +682,7 @@ <h2 id="variant-modal-title">New Variant</h2>
</span>
</td>
</tr>
`).join('');
`}).join('');
}

async function loadVariants() {
Expand Down
15 changes: 12 additions & 3 deletions server/src/db/insights-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ export interface ResponseAnalysis {
analysisNote: string;
}

export interface MemberOutreachWithUser extends MemberOutreach {
slack_display_name: string | null;
slack_real_name: string | null;
}

// Input types
export interface CreateInsightTypeInput {
name: string;
Expand Down Expand Up @@ -1295,9 +1300,13 @@ export class InsightsDatabase {
/**
* Get recent outreach history for admin dashboard
*/
async getRecentOutreach(limit = 50): Promise<MemberOutreach[]> {
const result = await query<MemberOutreach>(
'SELECT * FROM member_outreach ORDER BY sent_at DESC LIMIT $1',
async getRecentOutreach(limit = 50): Promise<MemberOutreachWithUser[]> {
const result = await query<MemberOutreachWithUser>(
`SELECT mo.*, sm.slack_display_name, sm.slack_real_name
FROM member_outreach mo
LEFT JOIN slack_user_mappings sm ON sm.slack_user_id = mo.slack_user_id
ORDER BY mo.sent_at DESC
LIMIT $1`,
[limit]
);
return result.rows;
Expand Down