Skip to content

Commit

Permalink
Merge pull request #1263 from Giveth/import_failed_donation_add_impor…
Browse files Browse the repository at this point in the history
…t_date

Add importDate to donation entity
  • Loading branch information
aminlatifi authored Jan 23, 2024
2 parents 028aefa + c91719c commit a0534d0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
15 changes: 15 additions & 0 deletions migration/1706012712969-add_import_date_to_donation_entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addImportDateToDonationEntity1706012712969
implements MigrationInterface
{
async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "donation" ADD COLUMN IF NOT EXISTS "importDate" TIMESTAMP WITH TIME ZONE`,
);
}

async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "donation" DROP COLUMN "importDate"`);
}
}
4 changes: 4 additions & 0 deletions src/entities/donation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ export class Donation extends BaseEntity {
@Column()
createdAt: Date;

@Field(type => Date, { nullable: true })
@Column({ nullable: true })
importDate: Date;

@Field(type => String, { nullable: true })
@Column({ nullable: true })
donationType?: string;
Expand Down
18 changes: 13 additions & 5 deletions src/repositories/donationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,20 @@ export const getPendingDonationsIds = (): Promise<{ id: number }[]> => {
hours: Number(process.env.DONATION_VERIFICAITON_EXPIRATION_HOURS),
})
.toDate();

return Donation.find({
where: {
status: DONATION_STATUS.PENDING,
isFiat: false,
createdAt: MoreThan(date),
},
where: [
{
status: DONATION_STATUS.PENDING,
isFiat: false,
createdAt: MoreThan(date),
},
{
status: DONATION_STATUS.PENDING,
isFiat: false,
importDate: MoreThan(date),
},
],
select: ['id'],
});
};
Expand Down
1 change: 1 addition & 0 deletions src/services/cronJobs/backupDonationImportJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const createBackupDonation = async (
);
const donation = (await findDonationById(Number(donationId))) as Donation;
donation!.createdAt = getCreatedAtFromMongoObjectId(donationData._id);
donation!.importDate = new Date();

return donation.save();
};

0 comments on commit a0534d0

Please sign in to comment.