-
Notifications
You must be signed in to change notification settings - Fork 715
fix: Logs page histogram api duplicate call #3998
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
Conversation
WalkthroughThe updates enhance the control flow in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant VueComponent
participant useLogsFunction
participant DataSource
User->>VueComponent: Interacts with UI
VueComponent->>useLogsFunction: Call useLogs()
useLogsFunction->>useLogsFunction: Check if query results `hits` are present
alt hits are present
useLogsFunction->>DataSource: Fetch histogram query data
DataSource-->>useLogsFunction: Return data
end
VueComponent->>VueComponent: Check if `searchObj.loading` is false
alt `searchObj.loading` is false
VueComponent->>VueComponent: Call loadLogsData()
end
VueComponent->>VueComponent: Verify if `config.isCloud` is true
alt `config.isCloud` is true
VueComponent->>VueComponent: Call getOrganizationThreshold(store)
end
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 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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- web/src/composables/useLogs.ts (2 hunks)
- web/src/plugins/logs/Index.vue (2 hunks)
Additional comments not posted (4)
web/src/plugins/logs/Index.vue (2)
528-530: Optimize loading logic by reducing duplicate calls.The added condition
if(searchObj.loading==false)before callingloadLogsData()is a good practice to prevent unnecessary API calls when data is already being loaded. This aligns with the PR objective to optimize API calls and improve performance.
530-530: Ensure cloud-specific configurations are handled appropriately.The condition checking
config.isCloud == "true"before executingMainLayoutCloudMixin.setup().getOrganizationThreshold(store)ensures that cloud-specific configurations are only applied when necessary. This is a good practice to prevent the execution of cloud-specific code in environments where it's not applicable.web/src/composables/useLogs.ts (2)
1628-1630: Conditional Logic to Fetch Histogram Data Based on Query HitsThe added conditional logic ensures that histogram data is fetched only if there are hits from the query. This is a good optimization as it prevents unnecessary data fetching and processing when there are no relevant results to display.
1646-1646: Conditional Logic for Pagination and Multi-Stream HandlingThis condition checks if the current page is the first one and there are query hits before proceeding to get the page count. Additionally, it handles conditions for multi-stream searches by setting up an appropriate error message. This is a crucial addition for performance optimization and correct data handling in scenarios involving multiple data streams.
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- web/src/composables/useLogs.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- web/src/composables/useLogs.ts
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- web/src/composables/useLogs.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- web/src/composables/useLogs.ts
e842cea to
631b251
Compare
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- web/src/composables/useLogs.ts (2 hunks)
- web/src/plugins/logs/Index.vue (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- web/src/composables/useLogs.ts
- web/src/plugins/logs/Index.vue
ff31dd6 to
12bdfdb
Compare
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- web/src/composables/useLogs.ts (2 hunks)
- web/src/plugins/logs/Index.vue (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- web/src/composables/useLogs.ts
- web/src/plugins/logs/Index.vue
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- web/src/composables/useLogs.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- web/src/composables/useLogs.ts
47eff30 to
6882c2e
Compare
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- tests/ui-testing/playwright-tests/logsquickmode.spec.js (1 hunks)
Additional context used
Path-based instructions (1)
tests/ui-testing/playwright-tests/logsquickmode.spec.js (1)
Pattern
**/*.js: You are a smart javascript/typescript pull request reviewer.
You are going to review all the javascript/typescript files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (1)
tests/ui-testing/playwright-tests/logsquickmode.spec.js (1)
182-183: LGTM! The added delay improves test reliability.The 2-second delay ensures that any asynchronous operations triggered by the refresh action have sufficient time to complete, reducing the likelihood of false negatives in the visibility check.
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- tests/ui-testing/playwright-tests/logsquickmode.spec.js (1 hunks)
- web/src/composables/useLogs.ts (2 hunks)
- web/src/plugins/logs/Index.vue (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- tests/ui-testing/playwright-tests/logsquickmode.spec.js
- web/src/composables/useLogs.ts
Additional comments not posted (5)
web/src/plugins/logs/Index.vue (5)
499-500: Verify the correctness of the condition.The condition ensures
loadLogsData()is called only when the organization identifier does not match and the loading state is false. This prevents redundant API calls.Ensure that the organization identifier and loading state are correctly managed throughout the codebase.
514-514: Verify the impact of commenting outsearchObj.loading = true.Commenting out this line indicates a shift in how loading states are managed. Ensure this does not lead to any unintended side effects.
Verify that the loading state is correctly managed elsewhere in the code.
526-529: Ensure the correct sequence of operations.The sequence of operations ensures
resetSearchObj()andresetStreamData()are called only ifsearchObj.loadingis false. This prevents unnecessary resets during loading.Verify that this sequence does not lead to any unintended side effects.
530-530: Verify the correctness of callingloadLogsData()after resets.Calling
loadLogsData()after the resets ensures data is loaded only when necessary. This prevents redundant API calls.Ensure that
loadLogsData()is correctly managed and does not lead to any unintended side effects.
526-530: Ensure the correct sequence of operations.The sequence of operations ensures
resetSearchObj()andresetStreamData()are called only ifsearchObj.loadingis false. This prevents unnecessary resets during loading.Verify that this sequence does not lead to any unintended side effects.
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- tests/ui-testing/playwright-tests/logsquickmode.spec.js (2 hunks)
- web/src/composables/useLogs.ts (3 hunks)
- web/src/plugins/logs/Index.vue (3 hunks)
Files skipped from review due to trivial changes (1)
- tests/ui-testing/playwright-tests/logsquickmode.spec.js
Additional comments not posted (10)
web/src/plugins/logs/Index.vue (5)
493-493: LGTM! Optimizes performance by avoiding redundant API calls.The conditional check ensures that
loadLogsData()is called only when necessary, preventing redundant API calls.
499-499: LGTM! Ensures efficient data loading.The conditional check ensures that
loadLogsData()is called only when the organization identifier has changed andsearchObj.loadingisfalse, optimizing performance.
514-514: Verify the rationale behind commenting out the loading state.The line setting
searchObj.loadingtotruehas been commented out. Ensure this change aligns with the new loading state management strategy.
526-531: LGTM! Ensures correct data reset and loading.The changes ensure that search and stream data are reset, URL query parameters are restored, and logs data are loaded only when
searchObj.loadingisfalse, optimizing performance.
530-530: LGTM! Ensures correct data loading sequence.The change ensures that
loadLogsData()is called after resetting search and stream data and restoring URL query parameters, preventing redundant API calls.web/src/composables/useLogs.ts (5)
1628-1629: EnsuresearchObj.data.queryResults.hitsis non-empty before callinggetHistogramQueryData.This change prevents unnecessary API calls when there are no query results.
1646-1650: Refine timeout logic to check for aggregations and non-empty hits.This change ensures that the timeout logic executes only when necessary, improving efficiency.
1650-1650: Set timeout forgetPageCountif query starts from the beginning and there are hits without aggregations.This change ensures that the page count is fetched only when necessary, optimizing performance.
1650-1650: Handle multi-stream search case by setting an error message for the histogram.This change provides a clear error message when the histogram is not available for multi-stream searches.
Line range hint
1628-1650:
Clean up code by removing unnecessary comments and code.This change improves readability and maintainability.
Summary by CodeRabbit
Bug Fixes
loadLogsData()only runs when necessary, enhancing performance and preventing unnecessary calls.New Features
Tests