Skip to content

Commit

Permalink
add qfround maximum cap to entity and logic
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 committed Jan 27, 2024
1 parent a0534d0 commit b67874c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
19 changes: 19 additions & 0 deletions migration/1706304290803-addQfRoundMaxRewardPercentage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addQfRoundMaxRewardPercentage1706304290803
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE qf_round
ADD COLUMN IF NOT EXISTS "maximumReward" FLOAT DEFAULT 0.2
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE qf_round
DROP COLUMN IF EXISTS "maximumReward"
`);
}
}
4 changes: 4 additions & 0 deletions src/entities/qfRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export class QfRound extends BaseEntity {
@Column()
allocatedFund: number;

@Field(type => Number)
@Column({ default: 0.2 })
maximumReward: number;

@Field(type => Number)
@Column()
minimumPassportScore: number;
Expand Down
3 changes: 3 additions & 0 deletions src/server/adminJs/tabs/qfRoundTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export const qfRoundTab = {
isActive: {
isVisible: true,
},
maximumReward: {
isVisible: true,
},
beginDate: {
isVisible: true,
},
Expand Down
3 changes: 1 addition & 2 deletions src/services/projectViewsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export const getQfRoundActualDonationDetails = async (
`);

let totalReward = qfRound!.allocatedFund;
const qfRoundMaxReward =
totalReward * Number(process.env.QF_ROUND_MAX_REWARD_PERCENTAGE || 0.2);
const qfRoundMaxReward = totalReward * Number(qfRound?.maximumReward || 0.2);
let totalWeight = rows.reduce((accumulator, currentRow) => {
return accumulator + currentRow.donationsSqrtRootSumSquared;
}, 0);
Expand Down

0 comments on commit b67874c

Please sign in to comment.