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

fixing endaoment id #1908

Merged
merged 1 commit into from
Jan 14, 2025
Merged
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
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
Loading