-
Notifications
You must be signed in to change notification settings - Fork 24
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
Process tracking update #998
Conversation
WalkthroughWalkthroughThe codebase underwent significant restructuring, focusing on refining process tracking. Key updates include renaming and reorganizing constants into Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API as campaignApis.ts
participant Constants as constants.ts
participant Utils as processTrackUtils.ts
Client->>API: POST /createProjectCampaign
API->>Constants: Import processTrackTypes, processTrackStatuses
API->>API: Check request.body.Activities
API->>Utils: Check ResourceDetails for facility and user
Utils->>Constants: Import processTrackTypes, processTrackStatuses
Utils->>Utils: Update process tracks
API->>Client: Return updated campaign response
Poem
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- utilities/project-factory/src/server/api/campaignApis.ts (5 hunks)
- utilities/project-factory/src/server/api/genericApis.ts (5 hunks)
- utilities/project-factory/src/server/config/constants.ts (1 hunks)
- utilities/project-factory/src/server/kafka/Listener.ts (4 hunks)
- utilities/project-factory/src/server/utils/campaignMappingUtils.ts (3 hunks)
- utilities/project-factory/src/server/utils/campaignUtils.ts (7 hunks)
- utilities/project-factory/src/server/utils/processTrackUtils.ts (2 hunks)
Files skipped from review due to trivial changes (1)
- utilities/project-factory/src/server/kafka/Listener.ts
Additional context used
Biome
utilities/project-factory/src/server/utils/processTrackUtils.ts
[error] 77-77: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
utilities/project-factory/src/server/config/constants.ts
[error] 1-1: Do not shadow the global "Error" property.
Consider renaming this variable. It's easy to confuse the origin of variables when they're named after a known global.
(lint/suspicious/noShadowRestrictedNames)
utilities/project-factory/src/server/utils/campaignMappingUtils.ts
[error] 51-51: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 53-53: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 206-206: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 207-207: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 209-209: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 219-232: This else clause can be omitted because previous branches break early.
Unsafe fix: Omit the else clause.
(lint/style/noUselessElse)
[error] 224-232: This else clause can be omitted because previous branches break early.
(lint/style/noUselessElse)
[error] 229-232: This else clause can be omitted because previous branches break early.
(lint/style/noUselessElse)
[error] 235-235: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
utilities/project-factory/src/server/api/genericApis.ts
[error] 67-69: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 657-689: This else clause can be omitted because previous branches break early.
Unsafe fix: Omit the else clause.
(lint/style/noUselessElse)
[error] 659-659: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 675-675: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 686-688: This else clause can be omitted because previous branches break early.
Unsafe fix: Omit the else clause.
(lint/style/noUselessElse)
[error] 841-841: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 876-876: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 878-878: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 882-882: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 972-972: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 973-973: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 246-246: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead(lint/complexity/noBannedTypes)
[error] 287-287: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead(lint/complexity/noBannedTypes)
utilities/project-factory/src/server/api/campaignApis.ts
[error] 29-29: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 39-39: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 41-44: This else clause can be omitted because previous branches break early.
Unsafe fix: Omit the else clause.
(lint/style/noUselessElse)
[error] 234-234: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 240-240: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 244-244: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 278-278: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 357-357: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 480-480: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
[error] 554-554: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 673-673: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 687-687: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 694-694: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 720-720: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 721-721: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 868-868: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
utilities/project-factory/src/server/utils/campaignUtils.ts
[error] 415-415: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 451-451: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 502-502: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 545-545: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 574-574: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 576-576: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 614-614: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 616-616: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 617-617: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 631-634: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 648-648: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 759-761: This else clause can be omitted because previous branches break early.
Unsafe fix: Omit the else clause.
(lint/style/noUselessElse)
[error] 874-874: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 881-881: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 882-882: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 883-883: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 884-884: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 1078-1078: Unsafe usage of optional chaining.
If it short-circuits with 'undefined' the evaluation will throw TypeError here:
(lint/correctness/noUnsafeOptionalChaining)
[error] 1100-1103: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
[error] 1104-1104: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
Additional comments not posted (14)
utilities/project-factory/src/server/utils/processTrackUtils.ts (6)
27-28
: Ensure the filtering logic is correct.The filtering logic for
processTrackTypes.error
andprocessTrackStatuses.toBeCompleted
seems appropriate.
Line range hint
42-66
: LGTM!The code changes are approved.
Tools
Biome
[error] 77-77: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
70-91
: VerifyprocessTrackTypes
andprocessTrackStatuses
.Ensure that the
processTrackTypes
andprocessTrackStatuses
used in the function are correct.Verification successful
Verified
processTrackTypes
andprocessTrackStatuses
.The
processTrackTypes
andprocessTrackStatuses
used in thecreateProcessTracks
function are correctly defined and used.
processTrackTypes
andprocessTrackStatuses
definitions found inutilities/project-factory/src/server/config/constants.ts
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the `processTrackTypes` and `processTrackStatuses` values. # Test: Search for the `processTrackTypes` and `processTrackStatuses` definitions in the codebase. rg --type ts $'processTrackTypes' rg --type ts $'processTrackStatuses'Length of output: 8054
Script:
#!/bin/bash # Extract the definitions of processTrackTypes and processTrackStatuses from constants.ts rg --multiline --multiline-dotall --context 10 'export const processTrackTypes' utilities/project-factory/src/server/config/constants.ts rg --multiline --multiline-dotall --context 10 'export const processTrackStatuses' utilities/project-factory/src/server/config/constants.tsLength of output: 1655
Tools
Biome
[error] 77-77: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
Line range hint
42-66
: Verify Kafka topic configuration.Ensure that the Kafka topic
KAFKA_UPDATE_PROCESS_TRACK_TOPIC
is correctly configured.Verification successful
Kafka topic configuration is set correctly.
The Kafka topic
KAFKA_UPDATE_PROCESS_TRACK_TOPIC
is configured in the environment variables with a default value of"update-process-track"
.
utilities/project-factory/src/server/config/index.ts
:KAFKA_UPDATE_PROCESS_TRACK_TOPIC: process.env.KAFKA_UPDATE_PROCESS_TRACK_TOPIC || "update-process-track",
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration. # Test: Search for the Kafka topic configuration in the codebase. rg --type json $'KAFKA_UPDATE_PROCESS_TRACK_TOPIC'Length of output: 49
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration in various file types. # Test: Search for the Kafka topic configuration in the codebase. rg 'KAFKA_UPDATE_PROCESS_TRACK_TOPIC' --type json --type yaml --type yml --type js --type ts --type envLength of output: 131
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration in various file types. # Test: Search for the Kafka topic configuration in the codebase. rg 'KAFKA_UPDATE_PROCESS_TRACK_TOPIC' --type json --type yaml --type js --type ts --type envLength of output: 120
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration in various file types. # Test: Search for the Kafka topic configuration in the codebase. rg 'KAFKA_UPDATE_PROCESS_TRACK_TOPIC' --type json --type yaml --type js --type tsLength of output: 383
Tools
Biome
[error] 77-77: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
70-91
: Verify Kafka topic configuration.Ensure that the Kafka topic
KAFKA_SAVE_PROCESS_TRACK_TOPIC
is correctly configured.Verification successful
Kafka topic configuration is verified.
The Kafka topic
KAFKA_SAVE_PROCESS_TRACK_TOPIC
is correctly configured with a fallback value.
utilities/project-factory/src/server/config/index.ts
:KAFKA_SAVE_PROCESS_TRACK_TOPIC: process.env.KAFKA_SAVE_PROCESS_TRACK_TOPIC || "save-process-track"
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration. # Test: Search for the Kafka topic configuration in the codebase. rg --type json $'KAFKA_SAVE_PROCESS_TRACK_TOPIC'Length of output: 47
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration. # Test: Search for the Kafka topic configuration in common configuration files. rg 'KAFKA_SAVE_PROCESS_TRACK_TOPIC' --type js --type ts --type env --type yaml --type yml --type toml --type iniLength of output: 140
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration. # Test: Search for the Kafka topic configuration in common configuration files. rg 'KAFKA_SAVE_PROCESS_TRACK_TOPIC' --type js --type ts --type yaml --type yml --type toml --type ini --type json # Additionally search for the topic in .env files without specifying the type. rg 'KAFKA_SAVE_PROCESS_TRACK_TOPIC' --glob '*.env'Length of output: 341
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration. # Test: Search for the Kafka topic configuration in common configuration files. rg 'KAFKA_SAVE_PROCESS_TRACK_TOPIC' --type js --type ts --type yaml --type toml --type ini --type json # Additionally search for the topic in .env files with debug information. rg 'KAFKA_SAVE_PROCESS_TRACK_TOPIC' --glob '*.env' --debugLength of output: 76852
Script:
#!/bin/bash # Description: Verify the Kafka topic configuration. # Test: Search for the Kafka topic configuration in common configuration files. rg 'KAFKA_SAVE_PROCESS_TRACK_TOPIC' --type js --type ts --type yaml --type toml --type json --glob '*.env' # Additionally search for the topic in all files to ensure coverage. rg 'KAFKA_SAVE_PROCESS_TRACK_TOPIC'Length of output: 577
Tools
Biome
[error] 77-77: This var should be declared at the root of the enclosing function.
The var is accessible in the whole body of the enclosing function.
To avoid confusion, it should be declared at the root of the enclosing function.(lint/correctness/noInnerDeclarations)
7-38
: Verify correctness of the query logic.The query logic changes look good but ensure that the table name and column names are correct.
utilities/project-factory/src/server/config/constants.ts (2)
112-122
: LGTM!The
processTrackTypes
constant is correctly defined.
124-128
: LGTM!The
processTrackStatuses
constant is correctly defined.utilities/project-factory/src/server/api/campaignApis.ts (4)
16-16
: Approved: Import statement change.The import statement for
processTrackStatuses
andprocessTrackTypes
from../config/constants
is correct.
791-791
: Approved: Added delay before producing modified messages.The change introduces a 2-second delay if there are activities in the request body. Ensure that this delay is necessary and consider optimizing it if possible.
814-816
: Approved: Added call topersistTrack
for facilities.The call to
persistTrack
ensures that the process track for facilities is marked as completed. Verify ifpersistTrack
handles errors correctly.
842-848
: Approved: Added call topersistTrack
for user creation.The call to
persistTrack
ensures that the process track for user creation is marked as in-progress. Verify ifpersistTrack
handles errors correctly.utilities/project-factory/src/server/utils/campaignUtils.ts (2)
544-544
: Verify the usage ofpersistTrack
function.Ensure that the
persistTrack
function is correctly used and that the added functionality aligns with the overall logic of the function.Verification successful
The usage of
persistTrack
function is correctly implemented.The
persistTrack
function is defined inutilities/project-factory/src/server/utils/processTrackUtils.ts
and is used appropriately incampaignUtils.ts
. The parameters passed topersistTrack
align with its definition and intended functionality.
utilities/project-factory/src/server/utils/processTrackUtils.ts
: Definition ofpersistTrack
.utilities/project-factory/src/server/utils/campaignUtils.ts
: Usage ofpersistTrack
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `persistTrack` function. # Test: Search for the function implementation. Expect: Correct usage of `persistTrack`. ast-grep --lang typescript --pattern $'function persistTrack($_, $_, $_, $_) { $$$ }'Length of output: 88
Script:
#!/bin/bash # Search for the definition of `persistTrack` function in the codebase ast-grep --lang typescript --pattern 'function persistTrack($_, $_, $_, $_) { $$$ }' # Search for any import statements of `persistTrack` in the codebase rg 'persistTrack' --type tsLength of output: 3464
Script:
#!/bin/bash # Extract the implementation of `persistTrack` function from `processTrackUtils.ts` ast-grep --lang typescript --pattern 'async function persistTrack($_, $_, $_, $_) { $$$ }' utilities/project-factory/src/server/utils/processTrackUtils.tsLength of output: 158
Script:
#!/bin/bash # Search for the definition of `persistTrack` function in the codebase with surrounding context rg 'async function persistTrack' -A 10 utilities/project-factory/src/server/utils/processTrackUtils.tsLength of output: 383
673-673
: Verify the usage ofcreateProcessTracks
function.Ensure that the
createProcessTracks
function is correctly used and that the added functionality aligns with the overall logic of the function.Verification successful
Verify the usage of
createProcessTracks
function.The
createProcessTracks
function is correctly used in theenrichAndPersistProjectCampaignForFirst
function. It is called after handling campaign creation or update, which aligns with the overall logic of the function.
utilities/project-factory/src/server/utils/campaignUtils.ts
: 673Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation of `createProcessTracks` function. # Test: Search for the function implementation. Expect: Correct usage of `createProcessTracks`. ast-grep --lang typescript --pattern $'function createProcessTracks($_) { $$$ }'Length of output: 2514
Script:
#!/bin/bash # Description: Verify the context and usage of `createProcessTracks` in `enrichAndPersistProjectCampaignForFirst`. # Search for the `enrichAndPersistProjectCampaignForFirst` function implementation. ast-grep --lang typescript --pattern $'function enrichAndPersistProjectCampaignForFirst($_) { $$$ }' --json # Search for all calls to `createProcessTracks` to see how it's used. rg 'createProcessTracks'Length of output: 611
Script:
#!/bin/bash # Description: List all function definitions in `campaignUtils.ts` to locate the correct function. # List all function definitions in `campaignUtils.ts`. ast-grep --lang typescript --pattern 'function $_($_) { $$$ }' --json utilities/project-factory/src/server/utils/campaignUtils.tsLength of output: 28144
Script:
#!/bin/bash # Description: Extract lines around the `createProcessTracks` call in `campaignUtils.ts` to understand the context. # Extract lines around the `createProcessTracks` call in `campaignUtils.ts`. sed -n '663,683p' utilities/project-factory/src/server/utils/campaignUtils.tsLength of output: 1149
No description provided.