Skip to content

Commit

Permalink
Merge pull request #118 from GeneralMagicio/addBatchNumbersWithTXsToP…
Browse files Browse the repository at this point in the history
…roject

Add batch numbers with txs to project
  • Loading branch information
aminlatifi authored Oct 30, 2024
2 parents 5a7e3d7 + d81e71c commit d85dc29
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
31 changes: 31 additions & 0 deletions migration/1730264518648-changeBatchNumberTXsFieldInPorjectTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class ChangeBatchNumberTXsFieldInPorjectTable1730264518648
implements MigrationInterface
{
name = 'ChangeBatchNumberTXsFieldInPorjectTable1730264518648';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "project" RENAME COLUMN "numberOfBatchMintingTransactions" TO "batchNumbersWithSafeTransactions"`,
);
await queryRunner.query(
`ALTER TABLE "project" DROP COLUMN "batchNumbersWithSafeTransactions"`,
);
await queryRunner.query(
`ALTER TABLE "project" ADD "batchNumbersWithSafeTransactions" integer array NOT NULL DEFAULT '{}'`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "project" DROP COLUMN "batchNumbersWithSafeTransactions"`,
);
await queryRunner.query(
`ALTER TABLE "project" ADD "batchNumbersWithSafeTransactions" integer`,
);
await queryRunner.query(
`ALTER TABLE "project" RENAME COLUMN "batchNumbersWithSafeTransactions" TO "numberOfBatchMintingTransactions"`,
);
}
}
6 changes: 3 additions & 3 deletions src/entities/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ export class Project extends BaseEntity {
@Column({ nullable: true })
icon?: string;

@Field({ nullable: true })
@Column({ nullable: true })
numberOfBatchMintingTransactions?: number;
@Field(_type => [Float], { nullable: true })
@Column('integer', { array: true, default: [] })
batchNumbersWithSafeTransactions?: number[];

// only projects with status active can be listed automatically
static pendingReviewSince(maximumDaysForListing: number) {
Expand Down
8 changes: 5 additions & 3 deletions src/scripts/syncDataWithJsonReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export async function updateRewardsForDonations(batchNumber: number) {
await updateNumberOfBatchMintingTransactionsForProject(
project,
matchedReportFile,
batchNumber,
);

await processReportForDonations(
Expand All @@ -189,13 +190,14 @@ export async function updateRewardsForDonations(batchNumber: number) {
async function updateNumberOfBatchMintingTransactionsForProject(
project: Project,
reportData: any,
batchNumber: number,
) {
const transactions = reportData.safe.proposedTransactions;
if (transactions.length > 0) {
if (!project.numberOfBatchMintingTransactions) {
project.numberOfBatchMintingTransactions = 1;
if (!project.batchNumbersWithSafeTransactions) {
project.batchNumbersWithSafeTransactions = [batchNumber];
} else {
project.numberOfBatchMintingTransactions += 1;
project.batchNumbersWithSafeTransactions.push(batchNumber);
}
await project.save();
}
Expand Down

0 comments on commit d85dc29

Please sign in to comment.