SmartfolioBackend / src /modules /applications /applications.controller.ts
ibrahimgulbutt's picture
Restore AI: Groq retired the Llama models
2f666f7
Raw History Blame Contribute Delete
2.36 kB
import { Body, Controller, Delete, Get, Param, Patch, Post, Query, Req, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { ApplicationsService, CreateApplicationDto, UpdateApplicationDto } from './applications.service';
import { APPLICATION_STATUSES } from './job-application.entity';
import { UsersService } from '../users/users.service';
@ApiTags('Applications')
@Controller('applications')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
export class ApplicationsController {
constructor(
private readonly applicationsService: ApplicationsService,
private readonly usersService: UsersService,
) {}
/**
* Tracking or updating an application is the strongest intent signal the
* portal has, so it drives the activity window that decides whose feed gets
* refreshed overnight. Not awaited: the bump is bookkeeping and must never
* turn a successful save into a failed request.
*/
private touch(userId: string) {
void this.usersService.markActive(userId).catch(() => undefined);
}
@Post()
@ApiOperation({
summary: 'Track a job (from feed via jobId, or manual entry)',
description: 'Pass { jobId } to snapshot a job from your feed, or { title, apply_url, ... } for a job found outside the portal. The entry is a frozen copy: feed expiry never affects it.',
})
create(@Req() req: any, @Body() dto: CreateApplicationDto) {
this.touch(req.user.id);
return this.applicationsService.create(req.user.id, dto);
}
@Get()
@ApiOperation({ summary: 'List tracked applications with counts by status' })
@ApiQuery({ name: 'status', required: false, enum: APPLICATION_STATUSES })
list(@Req() req: any, @Query('status') status?: string) {
return this.applicationsService.list(req.user.id, status);
}
@Patch(':id')
@ApiOperation({ summary: 'Update status, notes, or applied date' })
update(@Req() req: any, @Param('id') id: string, @Body() dto: UpdateApplicationDto) {
this.touch(req.user.id);
return this.applicationsService.update(req.user.id, id, dto);
}
@Delete(':id')
@ApiOperation({ summary: 'Remove a tracked application' })
remove(@Req() req: any, @Param('id') id: string) {
return this.applicationsService.remove(req.user.id, id);
}
}