Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add importDate to donation entity #1263

Merged
merged 2 commits into from
Jan 23, 2024
Merged
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
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();
};
Loading