Skip to content

Commit

Permalink
Merge pull request #1908 from Giveth/feat/check_periodically_endaoment
Browse files Browse the repository at this point in the history
fixing endaoment id
  • Loading branch information
kkatusic authored Jan 14, 2025
2 parents 1374e40 + 9f5752b commit 2825385
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/services/cronJobs/checkAndUpdateEndaomentProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { schedule } from 'node-cron';
import { Not } from 'typeorm';
import config from '../../config';
import { Project, ProjStatus } from '../../entities/project';
import { Organization } from '../../entities/organization';
import { logger } from '../../utils/logger';

// Runs once a month
Expand All @@ -19,14 +20,23 @@ export const runCheckAndUpdateEndaomentProject = async () => {

schedule(cronJobTime, async () => {
logger.debug('runCheckAndUpdateEndaomentProject() has been started');
logger.debug('ProjStatus.cancelled value:', ProjStatus.cancelled);
try {
// Fetch all projects with organizationId = 5
const projects = await Project.find({
where: { organizationId: 5, statusId: Not(ProjStatus.cancelled) },
const endaomentOrganization = await Organization.findOne({
where: { label: 'endaoment' },
});

logger.debug('Projects fetched:', projects.length);
if (!endaomentOrganization) {
logger.error('Endaoment organization not found.');
return;
}

// Fetch all Endaoment projects
const projects = await Project.find({
where: {
organizationId: endaomentOrganization?.id,
statusId: Not(ProjStatus.cancelled),
},
});

for (const project of projects) {
try {
Expand Down

0 comments on commit 2825385

Please sign in to comment.