import { AuthorStats } from '../services/author-stats-aggregator.service'; interface OKRData { authorName: string; role?: string; reviewPeriod?: string; strongPoints: string[]; weakPoints: string[]; knowledgeGaps: string[]; okr3Month: { objective: string; keyResults: Array<{ kr: string; why: string; actionSteps?: string[] }>; }; okr6Month?: { objective: string; keyResults: Array<{ kr: string; why: string }>; }; okr12Month?: { objective: string; keyResults: Array<{ kr: string; why: string }>; }; actionPlan?: Array<{ area: string; action: string; timeline: string; success: string; support: string; }>; authorStats: AuthorStats; historicalOkrs?: any[]; // Historical OKR data } /** * Format comprehensive OKR data into HTML */ export function formatOKRToHTML(data: OKRData): string { const { authorName, role, reviewPeriod, strongPoints, weakPoints, knowledgeGaps, okr3Month, okr6Month, okr12Month, actionPlan, authorStats, historicalOkrs = [], } = data; // Extract author slug for back button const authorSlug = authorName.toLowerCase().replace(/[^a-z0-9]/g, '_'); return ` OKR Profile - ${authorName}
← Back to Dashboard

🎯 Complete OKR Profile

${authorName}

Generated on ${new Date().toLocaleDateString()}

📊 Developer Assessment

💪 Strong Points
    ${strongPoints.map((point: string) => `
  • ${point}
  • `).join('')}
⚠️ Growth Areas
    ${weakPoints.map((point: string) => `
  • ${point}
  • `).join('')}
🧩 Knowledge Gaps
    ${knowledgeGaps.map((gap: string) => `
  • ${gap}
  • `).join('')}

🎯 3-Month Objective

${okr3Month.objective}
${okr3Month.keyResults .map( (kr: any, i: number) => `
KR ${i + 1}
${kr.kr}
Why: ${kr.why}
${ kr.actionSteps && kr.actionSteps.length > 0 ? `
✓ Action Steps:
    ${kr.actionSteps.map((step: string) => `
  • ${step}
  • `).join('')}
` : '' }
` ) .join('')}
${ okr6Month || okr12Month ? `

📅 Long-Term Objectives

${ okr6Month ? `
📆 6-Month Objective
${okr6Month.objective}
${okr6Month.keyResults .map( (kr: any, i: number) => `
KR ${i + 1}: ${kr.kr}
Why: ${kr.why}
` ) .join('')}
` : '' } ${ okr12Month ? `
📅 12-Month Objective
${okr12Month.objective}
${okr12Month.keyResults .map( (kr: any, i: number) => `
KR ${i + 1}: ${kr.kr}
Why: ${kr.why}
` ) .join('')}
` : '' }
` : '' } ${ actionPlan && actionPlan.length > 0 ? `

🚀 Action Plan

${actionPlan .map( (item: any) => ` ` ) .join('')}
Area Action Timeline Success Criteria Support Needed
${item.area} ${item.action} ${item.timeline} ${item.success} ${item.support}
` : '' }

📊 Current Metrics

${authorStats.quality.toFixed(1)}/10

Code Quality

${getQualityNote(authorStats.quality)}

${authorStats.complexity.toFixed(1)}/10

Complexity

${getComplexityNote(authorStats.complexity)}

${authorStats.tests.toFixed(1)}/10

Test Coverage

${getTestNote(authorStats.tests)}

${authorStats.impact.toFixed(1)}/10

Impact

${getImpactNote(authorStats.impact)}
Tech Debt: ${authorStats.techDebt.toFixed(1)}h accumulated
${ historicalOkrs && historicalOkrs.length > 1 ? `

📜 OKR History

Track progress and evolution over time (${historicalOkrs.length} total records)

${historicalOkrs .slice(1) .map((okr: any, index: number) => { const date = new Date(okr.generatedAt).toLocaleDateString(); const isFirst = index === 0; return `

💪 Strong Points
    ${okr.strongPoints?.map((p: string) => `
  • ${p}
  • `).join('') || '
  • No data
  • '}
⚠️ Growth Areas
    ${okr.weakPoints?.map((p: string) => `
  • ${p}
  • `).join('') || '
  • No data
  • '}
🧩 Knowledge Gaps
    ${okr.knowledgeGaps?.map((g: string) => `
  • ${g}
  • `).join('') || '
  • No data
  • '}
${ okr.okr3Month ? `
🎯 3-Month Objective

${okr.okr3Month.objective}

${ okr.okr3Month.keyResults ?.map( (kr: any, i: number) => `
KR ${i + 1}: ${kr.kr}
` ) .join('') || '' }
` : '' }
`; }) .join('')}
` : '' }
Generated by CodeWave OKR Agent on ${new Date().toLocaleDateString()}
`; } // Helper functions for metric notes function getQualityNote(score: number): string { if (score >= 8) return 'Excellent code quality'; if (score >= 6) return 'Good quality, room for improvement'; return 'Focus area for improvement'; } function getComplexityNote(score: number): string { if (score <= 3) return 'Simple, maintainable code'; if (score <= 6) return 'Moderate complexity'; return 'High complexity, consider simplification'; } function getTestNote(score: number): string { if (score >= 8) return 'Excellent test coverage'; if (score >= 6) return 'Good coverage, could be improved'; return 'Needs more test coverage'; } function getImpactNote(score: number): string { if (score >= 8) return 'High business impact'; if (score >= 6) return 'Moderate impact'; return 'Growing impact potential'; }