Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/sponsors/sponsors.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function createMockQueryBuilder(result: { raw?: unknown; many?: unknown[] }) {
andWhere: jest.fn().mockReturnThis(),
innerJoin: jest.fn().mockReturnThis(),
orderBy: jest.fn().mockReturnThis(),
addOrderBy: jest.fn().mockReturnThis(),
take: jest.fn().mockReturnThis(),
skip: jest.fn().mockReturnThis(),
getRawOne: jest.fn().mockResolvedValue(result.raw),
Expand Down Expand Up @@ -187,6 +188,8 @@ describe('SponsorsService', () => {
await service.activeBounties('sponsor-1');

expect(bountyRepo.createQueryBuilder).toHaveBeenCalledWith('bounty');
expect(qb.orderBy).toHaveBeenCalledWith('bounty.createdAt', 'DESC');
expect(qb.addOrderBy).toHaveBeenCalledWith('bounty.id', 'DESC');
expect(qb.where).toHaveBeenCalledWith('bounty.sponsorId = :sponsorId', {
sponsorId: 'sponsor-1',
});
Expand Down Expand Up @@ -215,6 +218,9 @@ describe('SponsorsService', () => {
{ sponsorId: 'sponsor-1', status: MilestoneStatus.FUNDED },
{ sponsorId: 'sponsor-1', status: MilestoneStatus.IN_PROGRESS },
],
order: { createdAt: 'DESC', id: 'DESC' },
take: 20,
skip: 0,
});
expect(result).toBe(milestones);
});
Expand Down
4 changes: 4 additions & 0 deletions src/sponsors/sponsors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export class SponsorsService {
BountyStatus.EXPIRED,
],
})
.orderBy('bounty.createdAt', 'DESC')
.addOrderBy('bounty.id', 'DESC')
.take(options.limit ?? 20)
.skip(options.offset ?? 0)
.getMany();
Expand Down Expand Up @@ -104,6 +106,7 @@ export class SponsorsService {
{ sponsorId, status: MilestoneStatus.FUNDED },
{ sponsorId, status: MilestoneStatus.IN_PROGRESS },
],
order: { createdAt: 'DESC', id: 'DESC' },
take: options.limit ?? 20,
skip: options.offset ?? 0,
});
Expand All @@ -116,6 +119,7 @@ export class SponsorsService {
): Promise<Array<{ milestoneId: string; title: string; progress: number }>> {
const milestones = await this.milestoneRepo.find({
where: { sponsorId },
order: { createdAt: 'DESC', id: 'DESC' },
take: options.limit ?? 20,
skip: options.offset ?? 0,
});
Expand Down