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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,8 @@ CLOUDFRONT_PROJECT_SHOWCASE_MEDIA_PRIVATE_KEY=""
CLOUDFRONT_PROJECT_SHOWCASE_MEDIA_PUBLIC_KEY=""
CLOUDFRONT_PROJECT_SHOWCASE_MEDIA_KEY_PAIR_ID=""
CLOUDFRONT_PROJECT_SHOWCASE_MEDIA_URL_EXPIRATION=""

CHALLENGES_DB_URL=""
MEMBERS_DB_URL=""
RESOURCES_DB_URL=""
SKILLS_DB_URL=""
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"@nestjs/swagger": "^11.0.3",
"@prisma/adapter-pg": "7.4.0",
"@prisma/client": "7.4.0",
"@topcoder/challenge-api-v6": "github:topcoder-platform/challenge-api-v6#prisma-client",
"@topcoder/member-api-v6": "github:topcoder-platform/member-api-v6#develop",
"@topcoder/resource-api-v6": "github:topcoder-platform/resource-api-v6#develop",
"@topcoder/standardized-skills-api": "github:topcoder-platform/standardized-skills-api#develop",
"axios": "^1.13.5",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
Expand Down
5,123 changes: 5,056 additions & 67 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/api/project-showcase-post/dto/challenge-metadata.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ApiProperty } from '@nestjs/swagger';

export class ChallengeMetadataDto {
@ApiProperty()
challengeId: string;

@ApiProperty()
numOfSubmissions: number;

@ApiProperty()
numOfRegistrants: number;

@ApiProperty({ type: [Object] })
skills: Array<{ id: string; name: string }>;

@ApiProperty()
track: string;

@ApiProperty({ type: [String] })
countries: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ export class ProjectShowcasePostListQueryDto extends PaginationDto {
projectId?: string | string[] | Record<string, unknown>;

@ApiPropertyOptional({
type: [String],
description: 'Filter by industry id (exact or $in pattern)',
})
@IsOptional()
@Transform(({ value }) => parseFilterInput(value))
industryId?: string | string[] | Record<string, unknown>;

@ApiPropertyOptional({
type: [String],
description: 'Filter by category id (exact or $in pattern)',
})
@IsOptional()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ProjectShowcasePostStatus } from '@prisma/client';
import { ProjectShowcasePostMediaDto } from './project-showcase-post-media.dto';
import { ChallengeMetadataDto } from './challenge-metadata.dto';

export class ProjectShowcasePostResponseDto {
@ApiProperty()
Expand All @@ -27,6 +28,9 @@ export class ProjectShowcasePostResponseDto {
@ApiProperty({ type: [Object] })
categories: Array<{ id: string; name: string }>;

@ApiPropertyOptional()
projectTitle?: string;

@ApiPropertyOptional({ type: [ProjectShowcasePostMediaDto] })
media?: ProjectShowcasePostMediaDto[];

Expand All @@ -41,4 +45,7 @@ export class ProjectShowcasePostResponseDto {

@ApiProperty()
updatedAt: Date;

@ApiPropertyOptional({ type: [ChallengeMetadataDto] })
challengeMetadata?: ChallengeMetadataDto[];
}
32 changes: 28 additions & 4 deletions src/api/project-showcase-post/project-showcase-post.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,20 @@ export class ProjectShowcasePostController {
@ApiQuery({ name: 'sort', required: false, type: String })
@ApiQuery({ name: 'status', required: false, type: String })
@ApiQuery({ name: 'projectId', required: false, type: String })
@ApiQuery({ name: 'industryId', required: false, type: String })
@ApiQuery({ name: 'categoryId', required: false, type: String })
@ApiQuery({
name: 'industryId',
required: false,
type: String,
isArray: true,
example: ['1', '2'],
})
@ApiQuery({
name: 'categoryId',
required: false,
type: String,
isArray: true,
example: ['2', '3'],
})
@ApiQuery({ name: 'challengeId', required: false, type: String })
@ApiQuery({ name: 'keyword', required: false, type: String })
@ApiResponse({
Expand Down Expand Up @@ -98,8 +110,20 @@ export class ProjectShowcasePostController {
@ApiQuery({ name: 'perPage', required: false, type: Number })
@ApiQuery({ name: 'sort', required: false, type: String })
@ApiQuery({ name: 'status', required: false, type: String })
@ApiQuery({ name: 'industryId', required: false, type: String })
@ApiQuery({ name: 'categoryId', required: false, type: String })
@ApiQuery({
name: 'industryId',
required: false,
type: String,
isArray: true,
example: ['5', '10'],
})
@ApiQuery({
name: 'categoryId',
required: false,
type: String,
isArray: true,
example: ['7', '12'],
})
@ApiQuery({ name: 'challengeId', required: false, type: String })
@ApiQuery({ name: 'keyword', required: false, type: String })
@ApiResponse({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,38 @@ jest.mock('src/shared/utils/cloudfront.utils', () => ({
signCloudFrontUrl: jest.fn((url: string) => `${url}?signed=1`),
}));

const challengeClientMock = {
challenge: {
findMany: jest.fn(),
},
};

const membersClientMock = {
member: {
findMany: jest.fn(),
},
};

const resourcesClientMock = {
resource: {
findMany: jest.fn(),
},
};

const skillsClientMock = {
skill: {
findMany: jest.fn(),
},
};

jest.mock('src/shared/global/external-prisma.client', () => ({
getChallengesPrismaClient: () => challengeClientMock,
getMembersPrismaClient: () => membersClientMock,
getResourcesPrismaClient: () => resourcesClientMock,
getSkillsPrismaClient: () => skillsClientMock,
getSubmitterRoleId: () => '732339e7-8e30-49d7-9198-cccf9451e221',
}));98

const { ProjectShowcasePostService: ProjectShowcasePostServiceClass } =
require('./project-showcase-post.service');

Expand Down Expand Up @@ -62,6 +94,10 @@ describe('ProjectShowcasePostService', () => {
},
},
],
project: {
id: BigInt(1001),
name: 'Project Title',
},
Comment thread
vas3a marked this conversation as resolved.
media: [
{
id: BigInt(101),
Expand Down Expand Up @@ -90,6 +126,41 @@ describe('ProjectShowcasePostService', () => {
],
});

challengeClientMock.challenge.findMany.mockResolvedValue([
{
id: '100',
numOfSubmissions: 5,
numOfRegistrants: 3,
track: { name: 'Development' },
skills: [{ skillId: 'skill-1' }, { skillId: 'skill-2' }],
},
]);

resourcesClientMock.resource.findMany.mockResolvedValue([
{ challengeId: '100', memberId: '42' },
{ challengeId: '100', memberId: '43' },
]);

membersClientMock.member.findMany.mockResolvedValue([
{
userId: BigInt(42),
country: 'US',
homeCountryCode: 'US',
competitionCountryCode: 'US',
},
{
userId: BigInt(43),
country: 'CA',
homeCountryCode: 'CA',
competitionCountryCode: 'CA',
},
]);

skillsClientMock.skill.findMany.mockResolvedValue([
{ id: 'skill-1', name: 'Skill One' },
{ id: 'skill-2', name: 'Skill Two' },
]);

service = new ProjectShowcasePostServiceClass(
prismaMock as any,
permissionServiceMock as any,
Expand Down Expand Up @@ -211,6 +282,19 @@ describe('ProjectShowcasePostService', () => {
}),
);
expect(response.status).toBe('DRAFT');
expect(challengeClientMock.challenge.findMany).toHaveBeenCalledWith(
expect.objectContaining({
where: { id: { in: ['100'] } },
}),
);
expect(resourcesClientMock.resource.findMany).toHaveBeenCalledWith(
expect.objectContaining({
where: {
challengeId: { in: ['100'] },
roleId: '732339e7-8e30-49d7-9198-cccf9451e221',
},
}),
);
});

it('creates a new project showcase post with media assets', async () => {
Expand Down
Loading
Loading