-
Notifications
You must be signed in to change notification settings - Fork 60
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
Improvereportperformance #3899
Improvereportperformance #3899
Conversation
WalkthroughThis pull request introduces updates across multiple project files, primarily focusing on incrementing the version number of the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant WebClient
participant ExecutionLogger
participant Database
User->>WebClient: Request report
WebClient->>ExecutionLogger: Send execution data
ExecutionLogger->>Database: Log execution statistics
Database-->>ExecutionLogger: Acknowledge receipt
ExecutionLogger-->>WebClient: Confirm data logged
WebClient-->>User: Display report
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (2)
Files skipped from review as they are similar to previous changes (2)
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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: 1
Outside diff range, codebase verification and nitpick comments (4)
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportStatistics.cs (1)
11-16
: Class implementation looks good; suggest adding XML documentation.The
AccountReportStatistics
class is well-implemented with appropriate properties for its intended use. However, adding XML documentation to the properties would enhance maintainability and understanding, especially for other developers or for future reference.Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportEntitiesDataMapping.cs (3)
Line range hint
143-187
: RefactorMapActivityStartData
to improve readability and maintainability.The method
MapActivityStartData
is quite lengthy and does several things, which can make it hard to read and maintain. Consider breaking it down into smaller, more focused methods. Additionally, the method directly manipulates properties ofAccountReportActivity
which could be encapsulated within the class.Consider refactoring the method to improve clarity and encapsulation. For example, you could introduce methods like
InitializeActivityExecutionId
orConfigureActivityStatistics
.Here's a potential refactor to encapsulate setting up the execution statistics:
+ private static void InitializeActivityExecutionId(Activity activity, Context context) { + activity.ExecutionId = Guid.NewGuid(); + activity.ParentExecutionId = context.BusinessFlow.CurrentActivitiesGroup.ExecutionId; + } + private static void ConfigureActivityStatistics(AccountReportActivity accountReportActivity, Activity activity) { + accountReportActivity.ChildsExecutionStatistics = new ExecutionStatistics { + Action = new ActionsStatistics { + TotalExecutable = activity.Acts.Count(x => x.Active) + } + }; + } public static AccountReportActivity MapActivityStartData(Activity activity, Context context) { InitializeActivityExecutionId(activity, context); AccountReportActivity accountReportActivity = new AccountReportActivity { Id = activity.ExecutionId, EntityId = activity.Guid, AccountReportDbActivityGroupId = activity.ParentExecutionId, ExecutionId = (Guid)WorkSpace.Instance.RunsetExecutor.RunSetConfig.ExecutionID, Seq = context.BusinessFlow.ExecutionLogActivityCounter - 1, Name = activity.ActivityName, Description = activity.Description, RunDescription = GetCalculatedValue(context, activity.RunDescription), Environment = ((GingerExecutionEngine)context.Runner).GingerRunner.ProjEnvironment.Name, EnvironmentId = ((GingerExecutionEngine)context.Runner).GingerRunner.ProjEnvironment.Guid, StartTimeStamp = activity.StartTimeStamp, VariablesBeforeExec = activity.Variables.Select(a => a.Name + "_:_" + a.Value + "_:_" + a.Description + "_:_" + a.Guid + "_:_" + a.SetAsInputValue + "_:_" + a.SetAsOutputValue + "_:_" + a.Publish).ToList(), ActivityGroupName = activity.ActivitiesGroupID, RunStatus = _InProgressStatus, IsPublished = activity.Publish, ExternalID = activity.ExternalID, ExternalID2 = activity.ExternalID2 }; ConfigureActivityStatistics(accountReportActivity, activity); return accountReportActivity; }
Line range hint
268-372
: OptimizeMapBusinessFlowStartData
andMapBusinessFlowEndData
for better performance and readability.The methods
MapBusinessFlowStartData
andMapBusinessFlowEndData
are complex and perform multiple operations which could be optimized for better performance and readability. Consider using more efficient LINQ queries or breaking down the methods into smaller, more focused sub-methods.Here's an example of how you might refactor the calculation of executable items to use more efficient LINQ methods and improve readability:
- int ChildExecutableItemsCountAction = 0; - foreach (Activity activity in businessFlow.Activities) { - ChildExecutableItemsCountAction = ChildExecutableItemsCountAction + activity.Acts.Count(x => x.Active); - } + int ChildExecutableItemsCountAction = businessFlow.Activities.Sum(activity => activity.Acts.Count(x => x.Active)); accountReportBusinessFlow.ChildsExecutionStatistics = new ExecutionStatistics { Action = new ActionsStatistics { TotalExecutable = ChildExecutableItemsCountAction }, Activity = new ActivitiesStatistics { TotalExecutable = businessFlow.Activities.Count(x => x.Active) } };This change not only makes the code more concise but also potentially improves performance by reducing the overhead of multiple method calls and iterations over collections.
Line range hint
395-433
: Review and potentially refactorMapRunnerStartData
andMapRunnerEndData
.The methods
MapRunnerStartData
andMapRunnerEndData
handle a lot of logic related to setting up and concluding the execution state of runners. These methods could benefit from refactoring to improve modularity and testability.Consider breaking down these methods into smaller parts that handle specific aspects of the runner's state. For example, separate methods for setting timestamps, handling environment details, and calculating execution rates could make the code cleaner and easier to maintain.
Here's a potential refactor for handling the environment setup:
+ private static void SetupRunnerEnvironment(AccountReportRunner accountReportRunner, GingerRunner gingerRunner) { + accountReportRunner.Environment = gingerRunner.ProjEnvironment.Name.ToString(); + accountReportRunner.EnvironmentId = gingerRunner.ProjEnvironment.Guid; + } public static AccountReportRunner MapRunnerStartData(GingerRunner gingerRunner, Context context) { gingerRunner.Executor.ExecutionId = Guid.NewGuid(); if (WorkSpace.Instance.RunsetExecutor.RunSetConfig.ExecutionID != null) { gingerRunner.Executor.ParentExecutionId = (Guid)WorkSpace.Instance.RunsetExecutor.RunSetConfig.ExecutionID; } AccountReportRunner accountReportRunner = new AccountReportRunner { Id = gingerRunner.Executor.ExecutionId, EntityId = gingerRunner.Guid, AccountReportDbRunSetId = gingerRunner.Executor.ParentExecutionId, ExecutionId = (Guid)WorkSpace.Instance.RunsetExecutor.RunSetConfig.ExecutionID, Seq = gingerRunner.Executor.ExecutionLoggerManager.GingerData.Seq, Name = gingerRunner.Name, StartTimeStamp = gingerRunner.Executor.StartTimeStamp, ApplicationAgentsMappingList = gingerRunner.ApplicationAgents.Select(a => a.AgentName + "_:_" + a.AppName).ToList(), RunStatus = _InProgressStatus, IsPublished = gingerRunner.Publish }; SetupRunnerEnvironment(accountReportRunner, gingerRunner); return accountReportRunner; }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (9)
- Ginger/Ginger/Ginger.csproj (1 hunks)
- Ginger/GingerCoreNET/GingerCoreNET.csproj (5 hunks)
- Ginger/GingerCoreNET/Reports/Ginger-Web-Client/3rdpartylicenses.txt (1 hunks)
- Ginger/GingerCoreNET/Reports/Ginger-Web-Client/index.html (1 hunks)
- Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportEntitiesDataMapping.cs (11 hunks)
- Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportExecutionLogger.cs (2 hunks)
- Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportStatistics.cs (1 hunks)
- Ginger/GingerCoreNETUnitTest/GingerCoreNETUnitTest.csproj (2 hunks)
- Ginger/GingerTest/GingerTest.csproj (1 hunks)
Files skipped from review due to trivial changes (4)
- Ginger/Ginger/Ginger.csproj
- Ginger/GingerCoreNET/Reports/Ginger-Web-Client/3rdpartylicenses.txt
- Ginger/GingerCoreNETUnitTest/GingerCoreNETUnitTest.csproj
- Ginger/GingerTest/GingerTest.csproj
Additional context used
GitHub Check: Codacy Static Code Analysis
Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportEntitiesDataMapping.cs
[failure] 45-45: Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportEntitiesDataMapping.cs#L45
Change the visibility of 'accountReportStatistics' or make it 'const' or 'readonly'.
[notice] 45-45: Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportEntitiesDataMapping.cs#L45
Use an immutable collection or reduce the accessibility of the public static field 'accountReportStatistics'.
Additional comments not posted (8)
Ginger/GingerCoreNET/Reports/Ginger-Web-Client/index.html (3)
11-12
: Cache control meta tags are appropriately added.The addition of
<meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate">
and<meta http-equiv="Pragma" content="no-cache">
is crucial for ensuring that the browser does not cache the page. This is especially important for an application like Ginger, where the most current data needs to be displayed.
17-17
: Stylesheet link updated correctly.The update to the
href
attribute of the stylesheet link fromstyles.0220388bb37cc84c.css
tostyles.0decbea244bacf15.css
ensures that the latest styles are applied to the web client. This is important for maintaining a consistent and modern user interface.
24-24
: JavaScript file link updated correctly.The update to the
src
attribute of the script link frommain.70d98b264f802619.js
tomain.438b2e8802ab272e.js
ensures that the latest JavaScript is loaded, which may include new features or bug fixes for the web client.Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportExecutionLogger.cs (2)
73-73
: Initialization of statistics list is appropriate; verify data aggregation impact.The addition of
AccountReportEntitiesDataMapping.accountReportStatistics = new List<AccountReportStatistics>();
at the start of data transmission ensures that old data does not persist incorrectly. However, it's important to verify that this change does not negatively impact the aggregation or reporting of data across multiple runs.
87-89
: Proper handling of statistics and response; verify impact on data handling.The re-initialization of
accountReportStatistics
and the explicit naming of the response variable inSendRunsetEndDataToCentralDbTaskAsync
enhance clarity and ensure that statistics are correctly managed. It's important to verify that these changes effectively manage data across multiple runs without unintended consequences.Ginger/GingerCoreNET/GingerCoreNET.csproj (3)
1433-1435
: Added new CSS file for styling updates.The inclusion of
styles.0decbea244bacf15.css
indicates updates to the styling of the web client. Verify that this CSS file is properly linked within the web client's HTML files and that it enhances the user interface without causing any visual regressions.Verification successful
CSS file is properly linked in the HTML. The CSS file
styles.0decbea244bacf15.css
is correctly referenced in theindex.html
file of the web client. It uses a technique to load asynchronously, which is efficient. However, verifying that it enhances the UI without visual regressions requires manual testing or automated visual regression tools.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the inclusion and linkage of the new CSS file in the web client's HTML files. # Test: Search for the CSS file reference in HTML files. Expect: Proper linkage and no visual regressions. rg --type html -A 5 $'styles.0decbea244bacf15.css'Length of output: 731
269-269
: Updated package version for Ginger.AccountReport.Contracts.The version update from
2024.4.1
to2024.4.1.5
is noted. Ensure that this version increment includes necessary bug fixes or enhancements as expected and that it does not introduce any breaking changes.Verification successful
Package version update is consistent across the codebase.
The
Ginger.AccountReport.Contracts
package is consistently referenced with version2024.4.1.5
across all project files. No discrepancies were found.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the package version update in other project files if applicable. # Test: Search for the package reference in other project files. Expect: Only occurrences of the new version. rg --type csproj -A 5 $'PackageReference Include="Ginger.AccountReport.Contracts"'Length of output: 114
Script:
#!/bin/bash # Description: Verify the package version update in other project files if applicable. # Find all .csproj files and search for the package reference. fd --extension csproj --exec rg 'PackageReference Include="Ginger.AccountReport.Contracts"' -A 5Length of output: 1663
1175-1177
: Added multiple JavaScript files for Ginger-Web-Client.The addition of multiple JavaScript files (
main.0271dbc8168ef484.js
,main.139c267c5febab4e.js
, etc.) suggests significant updates or enhancements to the web client's functionality. Ensure that these files are correctly referenced in the web client and that their inclusion does not impact the load times or performance negatively.Also applies to: 1181-1183, 1187-1189, 1190-1192, 1199-1201, 1208-1210, 1214-1216, 1250-1252, 1256-1258, 1262-1264, 1271-1273, 1274-1275
@@ -41,7 +42,7 @@ | |||
//select template | |||
static HTMLReportConfiguration _HTMLReportConfig = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<HTMLReportConfiguration>().FirstOrDefault(x => x.IsDefault); | |||
static string _InProgressStatus = "In Progress"; | |||
|
|||
public static List<AccountReportStatistics> accountReportStatistics= new List<AccountReportStatistics>(); |
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.
Consider making accountReportStatistics
immutable or less accessible.
The static list accountReportStatistics
is publicly accessible, which can lead to unintended modifications from various parts of the application, potentially leading to data races or inconsistent states. Consider making this list immutable or reducing its accessibility to protect its integrity.
Apply this diff to make the list readonly, which is a minimal change to ensure that the list itself cannot be reassigned:
- public static List<AccountReportStatistics> accountReportStatistics = new List<AccountReportStatistics>();
+ public static readonly List<AccountReportStatistics> accountReportStatistics = new List<AccountReportStatistics>();
Alternatively, if the design permits, consider using an immutable collection type or encapsulating the list more strictly.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public static List<AccountReportStatistics> accountReportStatistics= new List<AccountReportStatistics>(); | |
public static readonly List<AccountReportStatistics> accountReportStatistics = new List<AccountReportStatistics>(); |
Tools
GitHub Check: Codacy Static Code Analysis
[failure] 45-45: Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportEntitiesDataMapping.cs#L45
Change the visibility of 'accountReportStatistics' or make it 'const' or 'readonly'.
[notice] 45-45: Ginger/GingerCoreNET/Run/RunListenerLib/CenteralizedExecutionLogger/AccountReportEntitiesDataMapping.cs#L45
Use an immutable collection or reduce the accessibility of the public static field 'accountReportStatistics'.
{ Key = Actvities, Value = businessFlow.Activities.Count(ac => ac.Status == eRunStatus.Failed || ac.Status == eRunStatus.Passed || ac.Status == eRunStatus.FailIgnored || ac.Status == eRunStatus.Stopped || ac.Status == eRunStatus.Completed) }); | ||
accountReportBusinessFlow.ChildsExecutionStatistics.Activity.TotalExecuted = businessFlow.Activities.Count(ac => ac.Status == eRunStatus.Failed || ac.Status == eRunStatus.Passed || ac.Status == eRunStatus.FailIgnored || ac.Status == eRunStatus.Stopped || ac.Status == eRunStatus.Completed); | ||
accountReportBusinessFlow.ChildsExecutionStatistics.Activity.TotalPassed = businessFlow.Activities.Count(ac => ac.Status == eRunStatus.Passed); | ||
accountReportBusinessFlow.ChildsExecutionStatistics.Activity.TotalExecutable = businessFlow.Activities.Count(x => x.Active && (x.Status == eRunStatus.Passed || x.Status == eRunStatus.Failed || x.Status == eRunStatus.FailIgnored || x.Status == eRunStatus.Blocked)); |
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.
need to check if we really need to calculate it differently than just count what is Active
{ | ||
if (businessFlow.Active) | ||
{ | ||
var bfStat = accountReportStatistics.Where(x => x.EntityId == businessFlow.Guid).FirstOrDefault(); |
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.
Use FirstOrDefault directly instead of where
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.
Done.
{ | ||
if(activity.Active) | ||
{ | ||
var stat = accountReportStatistics.Where(x => x.EntityId == activity.Guid).FirstOrDefault(); |
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.
Use FirstOrDefault instead of where directly
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.
Done.
Thank you for your contribution.
Before submitting this PR, please make sure:
Summary by CodeRabbit
New Features
Ginger.AccountReport.Contracts
package to version2024.4.1.6
, introducing potential new features and improvements.Documentation
ngx-cookie-service
.Bug Fixes