Skip to content

Commit a04c316

Browse files
Merge pull request #3 from codebuilderinc/fix/job-fetching-and-pagination
2 parents f9b2d95 + aece33d commit a04c316

File tree

9 files changed

+17
-57
lines changed

9 files changed

+17
-57
lines changed

src/common/pagination/pagination.args.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { ArgsType } from '@nestjs/graphql';
2+
import { Type } from 'class-transformer';
23
import { Field } from '../decorators/field.decorator';
34

45
@ArgsType()
56
export class PaginationArgs {
7+
@Type(() => Number)
68
@Field({
79
name: 'skip',
810
description: 'Number of records to skip (offset based pagination).',
@@ -36,6 +38,7 @@ export class PaginationArgs {
3638
})
3739
before?: string;
3840

41+
@Type(() => Number)
3942
@Field({
4043
name: 'first',
4144
description: 'Max number of items to return going forward from the cursor.',
@@ -47,6 +50,7 @@ export class PaginationArgs {
4750
})
4851
first?: number;
4952

53+
@Type(() => Number)
5054
@Field({
5155
name: 'last',
5256
description: 'Max number of items to return going backward from the cursor.',

src/events/events.gateway.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,22 @@ export class EventsGateway implements OnGatewayConnection, OnGatewayDisconnect {
3232
server: Server;
3333

3434
private getClientQuery(client: Socket): Record<string, unknown> {
35-
console.log('wtf121212');
3635
return client.handshake.query;
3736
}
3837

3938
public broadcastAll(event_name: string, message: Record<string, unknown>) {
40-
console.log('assdasda');
4139
this.server.emit(event_name, message);
4240
}
4341

4442
public handleConnection(client: Socket) {
45-
console.log('whaaaat');
4643
const { user_id } = this.getClientQuery(client);
47-
44+
4845
console.log('WssGateway: handleConnection', { user_id });
4946

5047
return this.broadcastAll('event', { connected: user_id });
5148
}
5249

5350
public handleDisconnect(client: Socket) {
54-
console.log('hwathwat');
5551
const { user_id } = this.getClientQuery(client);
5652

5753
console.log('WssGateway: handleDisconnect', { user_id });
@@ -61,21 +57,17 @@ export class EventsGateway implements OnGatewayConnection, OnGatewayDisconnect {
6157

6258
@SubscribeMessage('tick')
6359
handleEvent(@MessageBody() data: unknown, @ConnectedSocket() client: Socket): WsResponse<unknown> {
64-
console.log('wtf111');
6560
const event = 'events';
6661
return { event, data };
6762
}
6863

6964
@SubscribeMessage('tick')
7065
findAll(@MessageBody() data: any): Observable<WsResponse<number>> {
71-
console.log('wtf222");');
7266
return from([1, 2, 3]).pipe(map((item) => ({ event: 'events', data: item })));
7367
}
7468

7569
@SubscribeMessage('identity')
7670
identity(@MessageBody() data: number): number {
77-
console.log('wtf23232');
78-
7971
return data;
8072
}
8173
}

src/jobs/job.controller.ts

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,8 @@ export class JobController {
101101
async findByCompany(
102102
@Param('companyId', ParseIntPipe) companyId: number,
103103
@Query() paginationArgs: PaginationArgs,
104-
@Query() orderBy: JobOrderByDto,
105-
@Query('skip') skipParam?: string,
106-
@Query('first') firstParam?: string
104+
@Query() orderBy: JobOrderByDto
107105
) {
108-
// Ensure pagination parameters are properly converted to numbers
109-
if (skipParam) {
110-
paginationArgs.skip = parseInt(skipParam, 10);
111-
}
112-
if (firstParam) {
113-
paginationArgs.first = parseInt(firstParam, 10);
114-
}
115-
116106
return this.jobService.findByCompany(companyId, paginationArgs, orderBy);
117107
}
118108

@@ -132,18 +122,8 @@ export class JobController {
132122
async findByTag(
133123
@Param('tagName') tagName: string,
134124
@Query() paginationArgs: PaginationArgs,
135-
@Query() orderBy: JobOrderByDto,
136-
@Query('skip') skipParam?: string,
137-
@Query('first') firstParam?: string
125+
@Query() orderBy: JobOrderByDto
138126
) {
139-
// Ensure pagination parameters are properly converted to numbers
140-
if (skipParam) {
141-
paginationArgs.skip = parseInt(skipParam, 10);
142-
}
143-
if (firstParam) {
144-
paginationArgs.first = parseInt(firstParam, 10);
145-
}
146-
147127
return this.jobService.findByTag(tagName, paginationArgs, orderBy);
148128
}
149129

@@ -187,18 +167,8 @@ export class JobController {
187167
@Query('companyId', new ParseIntPipe({ optional: true })) companyId?: number,
188168
@Query('location') location?: string,
189169
@Query('isRemote') isRemote?: boolean,
190-
@Query('tags') tags?: string,
191-
@Query('skip') skipParam?: string,
192-
@Query('first') firstParam?: string
170+
@Query('tags') tags?: string
193171
) {
194-
// Ensure pagination parameters are properly converted to numbers
195-
if (skipParam) {
196-
paginationArgs.skip = parseInt(skipParam, 10);
197-
}
198-
if (firstParam) {
199-
paginationArgs.first = parseInt(firstParam, 10);
200-
}
201-
202172
console.log('Pagination params:', { skip: paginationArgs.skip, first: paginationArgs.first });
203173

204174
return this.jobService.findAll({

src/jobs/reddit.service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ export class RedditService {
7272
data: post,
7373
},
7474
};
75-
// EARLY STOP: if this job already exists we assume all subsequent
76-
// posts are older (API returns newest first) and can stop processing.
75+
// Check if job already exists - if so, skip it but continue processing others
7776
const exists = await this.jobService.jobExists(post.url);
7877
if (exists) {
79-
this.logger.log(`Encountered existing Reddit job ${post.url}; stopping further processing.`);
80-
break;
78+
this.logger.log(`Skipping existing Reddit job ${post.url}`);
79+
continue;
8180
}
8281
const upsertedJob = await this.jobService.upsertJob(jobInput);
8382
// Send notifications for new jobs

src/jobs/web3career.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ export class Web3CareerService {
5252
data: job,
5353
},
5454
};
55-
// EARLY STOP: if job already exists assume remaining are older.
55+
// Check if job already exists - if so, skip it but continue processing others
5656
const exists = await this.jobService.jobExists(job.apply_url);
5757
if (exists) {
58-
this.logger.log(`Encountered existing Web3Career job ${job.apply_url}; stopping further processing.`);
59-
break;
58+
this.logger.log(`Skipping existing Web3Career job ${job.apply_url}`);
59+
continue;
6060
}
6161
const upserted = await this.jobService.upsertJob(jobInput);
6262
newJobs.push(upserted);

src/users/user.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class UserController {
1212
@UseGuards(RedisAuthGuard)
1313
@Get('/wallet/:token/sell')
1414
@Api({ summary: 'Example secured endpoint', description: 'Placeholder user wallet endpoint.', envelope: true })
15-
walletTokenSell(@Param('username') _username: string) {
15+
walletTokenSell(@Param('token') token: string) {
1616
return { message: 'Not yet implemented' };
1717
}
1818
}

src/users/user.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class UserService {
3030
const hashedPassword = await this.passwordService.hashPassword(changePassword.newPassword);
3131

3232
return this.prisma.user.update({
33-
data: {},
33+
data: { password: hashedPassword },
3434
where: { id: userId },
3535
});
3636
}

src/wss/wss.adapter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class CustomRedisIoAdapter extends IoAdapter {
2424
}
2525

2626
public createIOServer(port: number, options?: ServerOptions): Server {
27-
//console.log('wut the fuck');
2827
const server = super.createIOServer(port, {
2928
...options,
3029
cors: cors_options_delegate,

src/wss/wss.gateway.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,14 @@ export class WssGateway implements OnGatewayConnection, OnGatewayDisconnect {
3535
constructor(private readonly logService: LogService) {}
3636

3737
private getClientQuery(client: io.Socket): { [key: string]: string } {
38-
console.log('ASDASDASD');
3938
return client.handshake.query as { [key: string]: string };
4039
}
4140

4241
public broadcastAll(event_name: string, message: Record<string, unknown>) {
43-
console.log('sadadsdasdasd');
4442
this.server.emit(event_name, message);
4543
}
4644

47-
handleConnection(client: io.Socket) {
48-
console.log('wtf');
49-
client.join('msgRoom');
45+
handleConnection(client: io.Socket) { client.join('msgRoom');
5046
const { user_id } = this.getClientQuery(client);
5147

5248
this.logService.info(`WssGateway: handleConnection ${user_id}`);

0 commit comments

Comments
 (0)