Spaces:
Sleeping
Sleeping
File size: 2,361 Bytes
6fb7573 a0eafe5 6fb7573 a0eafe5 6fb7573 2f666f7 6fb7573 a0eafe5 6fb7573 a0eafe5 6fb7573 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 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);
}
}
|