Skip to content

Commit

Permalink
Add streamed mini donations to qf round
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz committed May 13, 2024
1 parent 61f196c commit 5b25537
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class RelateCurrentMiniStreamDonationsToQfRounds1715521134568
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
UPDATE donation
SET "qfRoundId" = qf_round.id
FROM project_qf_rounds_qf_round, qf_round
WHERE donation."recurringDonationId" IS NOT NULL
AND donation."projectId" = project_qf_rounds_qf_round."projectId"
AND project_qf_rounds_qf_round."qfRoundId" = qf_round."id"
AND donation."createdAt" BETWEEN qf_round."beginDate" AND qf_round."endDate"
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {

Check failure on line 18 in migration/1715521134568-relate_current_mini_stream_donations_to_qf_Rounds.ts

View workflow job for this annotation

GitHub Actions / test

'queryRunner' is defined but never used. Allowed unused args must match /^_/u
// Since the `up` migration changes data based on existing conditions rather than schema,
// rolling back would ideally require prior knowledge of the previous state, which might
// not be practical or possible to restore.
// Therefore, typically for data migrations, the down method might be left empty or
// could reset changes based on specific requirements.
}
}
22 changes: 11 additions & 11 deletions src/services/recurringDonationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { updateUserTotalDonated, updateUserTotalReceived } from './userService';
import config from '../config';
import { User } from '../entities/user';
import { NOTIFICATIONS_EVENT_NAMES } from '../analytics/analytics';
import { relatedActiveQfRoundForProject } from './qfRoundService';

// Initially it will only be monthly data
export const priceDisplay = 'month';
Expand Down Expand Up @@ -212,17 +213,16 @@ export const createRelatedDonationsToStream = async (
amount: donation.amount,
});

// TODO - uncomment this when QF is enabled
// const activeQfRoundForProject = await relatedActiveQfRoundForProject(
// project.id,
// );
//
// if (
// activeQfRoundForProject &&
// activeQfRoundForProject.isEligibleNetwork(networkId)
// ) {
// donation.qfRound = activeQfRoundForProject;
// }
const activeQfRoundForProject = await relatedActiveQfRoundForProject(
project.id,
);

if (
activeQfRoundForProject &&
activeQfRoundForProject.isEligibleNetwork(networkId)
) {
donation.qfRound = activeQfRoundForProject;
}

const { givbackFactor, projectRank, bottomRankInRound, powerRound } =
await calculateGivbackFactor(project.id);
Expand Down

0 comments on commit 5b25537

Please sign in to comment.