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

Task #215480: [BE] Add org_id in Camp and update using group_users member_type and status active using user_id Task #215497 [BE] Add org_id in program_beneficaires and update org_id using facilitator_id by joining program_facilitator. user_id #904

Open
wants to merge 2 commits into
base: release-2.8.0
Choose a base branch
from

Conversation

sagarkoshti1990
Copy link
Collaborator

@sagarkoshti1990 sagarkoshti1990 commented Mar 14, 2024

https://tracker.tekdi.net/issues/215480

https://tracker.tekdi.net/issues/215497

I have ensured that following Pull Request Checklist is taken care of before sending this PR

  • Code is formatted as per format decided
  • Updated acceptance criteria in tracker
  • Updated test cases in test-cases-tracker
  • Updated new API endpoint if any in common postman collection
  • Updated DB changes in db-tracker if any

Summary by CodeRabbit

  • Chores
    • Scheduled tasks have been adjusted for better operational timing.
  • New Features
    • Introduced a new housekeeping task to maintain database integrity.
  • Bug Fixes
    • Improved error handling in database query operations to enhance stability.

Copy link

coderabbitai bot commented Mar 14, 2024

Walkthrough

The recent changes involve modifying the scheduling of various cron jobs in a NestJS application, specifically by commenting out cron schedule annotations in several files. Additionally, a new HousekeepingCron service has been introduced to perform daily database maintenance tasks. The HasuraService has been updated to include a method for handling response exceptions, enhancing error management in the application.

Changes

File(s) Change Summary
.../campEnd.cron.ts, .../faAttendanceProcessing.cron.ts, .../faFaceIndexing.cron.ts, .../faUserIndexing.cron.ts, .../prepareCertificateHtml.cron.ts Cron scheduling annotations commented out, affecting job scheduling.
.../cron.module.ts Added HousekeepingCron module to imports and dependencies.
.../housekeeping.cron.ts Introduced a cron job for daily database maintenance, updating org_id in specific tables.
.../services/hasura/hasura.service.ts Added handleResponseException method for improved exception handling in HasuraService.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

sonarcloud bot commented Mar 14, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 8

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between c1481e3 and cc8bc76.
Files selected for processing (8)
  • src/src/cron/campEnd.cron.ts (1 hunks)
  • src/src/cron/cron.module.ts (2 hunks)
  • src/src/cron/faAttendanceProcessing.cron.ts (1 hunks)
  • src/src/cron/faFaceIndexing.cron.ts (1 hunks)
  • src/src/cron/faUserIndexing.cron.ts (1 hunks)
  • src/src/cron/housekeeping.cron.ts (1 hunks)
  • src/src/cron/prepareCertificateHtml.cron.ts (1 hunks)
  • src/src/services/hasura/hasura.service.ts (1 hunks)
Additional comments: 10
src/src/cron/cron.module.ts (2)
  • 12-12: The import of HousekeepingCron is correctly added following NestJS conventions and is consistent with the structure of the module.
  • 25-25: The addition of HousekeepingCron to the providers array is correctly implemented, ensuring that it is available for dependency injection throughout the module.
src/src/cron/campEnd.cron.ts (1)
  • 11-11: The cron schedule annotation for updateEndCamp has been commented out, effectively disabling the scheduled execution. Please verify that this change is intentional and consider adding a comment to document the reason for this temporary disablement.
src/src/cron/faUserIndexing.cron.ts (1)
  • 22-22: The cron schedule annotation for createCollectionUsers has been commented out, disabling its scheduled execution. Please confirm this change was made intentionally and document the reason for this temporary disablement to maintain clarity.
src/src/cron/housekeeping.cron.ts (1)
  • 10-10: The cron schedule annotations for updateCamp and updateLeaner methods are commented out, indicating these jobs are not currently scheduled. Please confirm this is intentional and document the reasoning.
src/src/cron/faAttendanceProcessing.cron.ts (1)
  • 22-22: The cron schedule annotation for markAttendanceCron has been commented out, disabling its scheduled execution. Please ensure this change is intentional and document the reason for this temporary disablement to maintain clarity.
src/src/services/hasura/hasura.service.ts (2)
  • 116-118: The integration of handleResponseException in the catch block of executeRawSql method is a good practice for centralized error handling, enhancing the service's robustness.
  • 121-127: The addition of handleResponseException method is a commendable improvement for managing exceptions more effectively by extracting and returning relevant error information.
src/src/cron/prepareCertificateHtml.cron.ts (1)
  • 26-26: The @Cron decorator usage for prepareCertificateHtml has been commented out, disabling its scheduled execution. Please confirm this change was made intentionally and document the reason for this temporary disablement to maintain clarity.
src/src/cron/faFaceIndexing.cron.ts (1)
  • 22-22: The cron schedule annotation for indexRekognitionUsers has been commented out. This change will prevent the method from being executed as a scheduled task. If this is intentional, ensure that the method's scheduling is managed elsewhere or document the reason for this change to avoid confusion.

src/src/cron/faFaceIndexing.cron.ts Show resolved Hide resolved
src/src/cron/housekeeping.cron.ts Show resolved Hide resolved
src/src/cron/housekeeping.cron.ts Show resolved Hide resolved
@@ -8,7 +8,7 @@ export class CampEndCron {
constructor(private hasuraService: HasuraService) {}

// Cronjob runs every day at 12am
@Cron('0 00 * * * ')
// @Cron('0 00 * * * ')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this and in other crons


// Cronjob runs every day at 12am
// @Cron('0/1 * * * *')
async updateCamp() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give it better name

}

// @Cron('0/1 * * * *')
async updateLeaner() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

give this better name

column_name: 'org_id',
});
console.log(column_create_or_exists);
if (column_create_or_exists?.exist) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see if we can use transaction start end?

AND sub.academic_year_id = pf.academic_year_id
WHERE g.id = sub.id;`;

const result1 = await this.hasuraService.executeRawSql(updateQuery);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use try catch, push to Sentry in case of failure

table_name: 'program_beneficiaries',
column_name: 'org_id',
});
if (column_create_or_exists?.exist) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use try catch, push to Sentry in case of failure

column_name: 'org_id',
});
if (column_create_or_exists?.exist) {
const updateQuery = `UPDATE program_beneficiaries AS pb
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see if we can use transaction start, end?

@@ -23,7 +23,7 @@ export class PrepareCertificateHtmlCron {
) {}

//cron issue certificate run every 5 minutes
@Cron(CronExpression.EVERY_5_MINUTES)
// @Cron(CronExpression.EVERY_5_MINUTES)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

@@ -19,7 +19,7 @@ export class FaUserIndexingCron {
}

//first cron runs for each hour's 5th minute eg: 10:05am, 11::05am
@Cron('05 * * * *')
// @Cron('05 * * * *')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

@@ -19,7 +19,7 @@ export class FaFaceIndexingCron {
}

//2nd cron runs for each hour's 15th minute eg: 10:15am, 11::15am
@Cron('15 * * * *')
// @Cron('15 * * * *')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

@@ -19,7 +19,7 @@ export class FaAttendanceProcessingCron {
}

//3rd cron runs for each hour's 25th minute eg: 10:25am, 11::25am
@Cron('25 * * * *')
// @Cron('25 * * * *')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

@sagarkoshti1990 sagarkoshti1990 changed the base branch from feat-po-user-flow to release-2.1.0 April 19, 2024 06:30
@sagarkoshti1990 sagarkoshti1990 changed the base branch from release-2.1.0 to release-2.2.0 May 22, 2024 07:09
@rushi-tekdi rushi-tekdi changed the base branch from release-2.2.0 to release-2.3.0 June 21, 2024 05:03
@sagarkoshti1990 sagarkoshti1990 changed the base branch from release-2.5.0 to release-2.6.0 August 30, 2024 05:38
@sagarkoshti1990 sagarkoshti1990 changed the base branch from release-2.7.0 to release-2.8.0 September 24, 2024 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants