- Make all AI endpoints (health scores + investment recommendations) fire-and-forget: POST returns immediately, frontend polls for results - Extend AI API timeout from 2-5 min to 10 min for both services - Add "last analysis failed — showing cached data" message to the Investment Recommendations panel (matches health score widgets) - Add status/error_message columns to ai_recommendations table - Remove nginx AI timeout overrides (no longer needed) - Users can now navigate away during AI processing without interruption Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { Controller, Get, Post, UseGuards, Req } from '@nestjs/common';
|
|
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
|
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
import { AllowViewer } from '../../common/decorators/allow-viewer.decorator';
|
|
import { InvestmentPlanningService } from './investment-planning.service';
|
|
|
|
@ApiTags('investment-planning')
|
|
@Controller('investment-planning')
|
|
@ApiBearerAuth()
|
|
@UseGuards(JwtAuthGuard)
|
|
export class InvestmentPlanningController {
|
|
constructor(private service: InvestmentPlanningService) {}
|
|
|
|
@Get('snapshot')
|
|
@ApiOperation({ summary: 'Get financial snapshot for investment planning' })
|
|
getSnapshot() {
|
|
return this.service.getFinancialSnapshot();
|
|
}
|
|
|
|
@Get('cd-rates')
|
|
@ApiOperation({ summary: 'Get latest CD rates from market data (backward compat)' })
|
|
getCdRates() {
|
|
return this.service.getCdRates();
|
|
}
|
|
|
|
@Get('market-rates')
|
|
@ApiOperation({ summary: 'Get all market rates grouped by type (CD, Money Market, High Yield Savings)' })
|
|
getMarketRates() {
|
|
return this.service.getMarketRates();
|
|
}
|
|
|
|
@Get('saved-recommendation')
|
|
@ApiOperation({ summary: 'Get the latest saved AI recommendation for this tenant' })
|
|
getSavedRecommendation() {
|
|
return this.service.getSavedRecommendation();
|
|
}
|
|
|
|
@Post('recommendations')
|
|
@ApiOperation({ summary: 'Trigger AI-powered investment recommendations (async — returns immediately)' })
|
|
@AllowViewer()
|
|
triggerRecommendations(@Req() req: any) {
|
|
return this.service.triggerAIRecommendations(req.user?.sub, req.user?.orgId);
|
|
}
|
|
}
|