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
7 changes: 5 additions & 2 deletions src/analytics/analytics.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Controller, Get, Param } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { AnalyticsService } from './analytics.service';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';

@ApiTags('analytics')
@Controller('analytics')
export class AnalyticsController {
constructor(private readonly analyticsService: AnalyticsService) {}

@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get('contributors/:userId')
forContributor(@Param('userId') userId: string) {
return this.analyticsService.forContributor(userId);
Expand Down
2 changes: 2 additions & 0 deletions src/common/entities/bounty.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Column,
CreateDateColumn,
Entity,
Index,
JoinColumn,
ManyToOne,
OneToOne,
Expand Down Expand Up @@ -37,6 +38,7 @@ export class Bounty {
@JoinColumn()
claimedBy: User | null;

@Index()
@Column({ type: 'varchar', nullable: true })
claimedById: string | null;

Expand Down
2 changes: 1 addition & 1 deletion src/common/entities/maintenance-pool.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class MaintenancePool {
@PrimaryGeneratedColumn('uuid')
id: string;

@Column()
@Column({ type: 'varchar', length: 150 })
name: string;

@ManyToOne(() => Repository, { onDelete: 'CASCADE', nullable: true })
Expand Down
4 changes: 2 additions & 2 deletions src/common/entities/milestone.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export class Milestone {
@Column()
repositoryId: string;

@Column()
@Column({ type: 'varchar', length: 255 })
title: string;

@Column({ type: 'text', nullable: true })
@Column({ type: 'varchar', length: 2000, nullable: true })
description: string | null;

@ManyToOne(() => User, { onDelete: 'SET NULL', nullable: true })
Expand Down
2 changes: 1 addition & 1 deletion src/common/entities/team-member-split.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class TeamMemberSplit {
userId: string;

/** Free-text label describing the member's contribution, e.g. "frontend". */
@Column({ type: 'varchar', nullable: true })
@Column({ type: 'varchar', length: 100, nullable: true })
role: string | null;

/** Percentage of the bounty payout, 0-100. Sum across a team must equal 100. */
Expand Down
4 changes: 4 additions & 0 deletions src/common/entities/webhook-event.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import {
Column,
CreateDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
} from 'typeorm';
import { WebhookEventStatus } from '../enums';

/** Audit log of every inbound webhook, verified or not, for replay/debugging. */
@Index(['eventType', 'status'])
@Index(['status', 'receivedAt'])
@Entity('webhook_events')
export class WebhookEvent {
@PrimaryGeneratedColumn('uuid')
Expand Down Expand Up @@ -37,6 +40,7 @@ export class WebhookEvent {
@Column({ type: 'text', nullable: true })
error: string | null;

@Index()
@CreateDateColumn()
receivedAt: Date;

Expand Down
3 changes: 2 additions & 1 deletion src/maintenance-pool/dto/create-pool.dto.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsOptional, IsString, IsUUID } from 'class-validator';
import { IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
import { AssetType } from '../../common/enums';
import { IsSupportedEscrowAsset } from '../../common/validators/money.validator';

export class CreatePoolDto {
@ApiProperty()
@IsString()
@MaxLength(150)
name: string;

@ApiProperty({ required: false })
Expand Down
4 changes: 3 additions & 1 deletion src/milestones/dto/create-milestone.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsISO8601, IsOptional, IsString, IsUUID } from 'class-validator';
import { IsISO8601, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
import { AssetType } from '../../common/enums';
import {
IsMoneyAmount,
Expand All @@ -18,11 +18,13 @@ export class CreateMilestoneDto {

@ApiProperty()
@IsString()
@MaxLength(255)
title: string;

@ApiProperty({ required: false })
@IsOptional()
@IsString()
@MaxLength(2000)
description?: string;

@ApiProperty()
Expand Down
11 changes: 9 additions & 2 deletions src/reputation/reputation.controller.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
import { Controller, Get, Param, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { ReputationService } from './reputation.service';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';

@ApiTags('reputation')
@Controller('reputation')
export class ReputationController {
constructor(private readonly reputationService: ReputationService) {}

@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Post(':userId/recompute')
recompute(@Param('userId') userId: string) {
return this.reputationService.computeAndSave(userId);
}

@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get(':userId')
latest(@Param('userId') userId: string) {
return this.reputationService.getLatest(userId);
}

@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get(':userId/history')
history(@Param('userId') userId: string) {
return this.reputationService.history(userId);
Expand Down
3 changes: 3 additions & 0 deletions src/teams/dto/create-team.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
IsOptional,
IsString,
IsUUID,
MaxLength,
ValidateNested,
} from 'class-validator';

Expand All @@ -17,6 +18,7 @@ export class TeamMemberSplitDto {
@ApiProperty({ required: false, example: 'frontend' })
@IsOptional()
@IsString()
@MaxLength(100)
role?: string;

@ApiProperty({ example: 40 })
Expand All @@ -27,6 +29,7 @@ export class TeamMemberSplitDto {
export class CreateTeamDto {
@ApiProperty()
@IsString()
@MaxLength(150)
name: string;

@ApiProperty({ required: false })
Expand Down