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

add many search feature #653

Merged
merged 10 commits into from
Jan 23, 2022
Merged

add many search feature #653

merged 10 commits into from
Jan 23, 2022

Conversation

MiccWan
Copy link
Collaborator

@MiccWan MiccWan commented Jan 19, 2022

  • fix GlobalErrorNode.getSelectedChildren
  • fix errors not recorded correctly in TraceCollection
  • fix showError should only traverse leaves
  • add SearchController in dbux-code
  • fix many search bugs
  • show search result in GlobalAnalysisView
  • focus SearchResultNode on search

#619

@MiccWan MiccWan requested a review from Domiii January 19, 2022 10:08
- fix `SearchBar` focus race condition
- fix wont search when press enter after mode switch
- fix undisposed handler errors
- merge search `SelectorType`s in `ContextNodeManager`
- add `DataNodeNode`
- use `DataNodeNode` on `DataFlowView`
- add `DataNode.applicationId`
- `traceSelection.isSelected` supports nodeId
@MiccWan MiccWan changed the title add SearchController in dbux-code add many search feature Jan 21, 2022
}

handleClick = () => {
const { applicationId, contextId } = this.context;
Copy link
Owner

Choose a reason for hiding this comment

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

@MiccWan add dp getter to ContextNode instead

import allApplications from '@dbux/data/src/applications/allApplications';
import BaseTreeViewNode from './BaseTreeViewNode';

export default class TraceNode extends BaseTreeViewNode {
get clickUserActionType() {
Copy link
Owner

@Domiii Domiii Jan 23, 2022

Choose a reason for hiding this comment

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

@MiccWan since this is part of Pathways: did you make sure whether pathways works as expected when making this change?
We generally want to avoid touching features that we are not currently working on them. If absolutely necessary, make the change, but then also make sure to test the corresponding changes.

Copy link
Collaborator Author

@MiccWan MiccWan Jan 25, 2022

Choose a reason for hiding this comment

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

Added getter of clickUserActionType which returns false to BaseTreeViewNode, so by default no UserEvent will be send on click.

@@ -33,18 +36,34 @@ export default class GlobalAnalysisViewController {
this.refresh();
}

handleSearch = async () => {
await this.refresh();
this.focusOnSearchResult();
Copy link
Owner

@Domiii Domiii Jan 23, 2022

Choose a reason for hiding this comment

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

@MiccWan no await for this?
Since race conditions in the focus controller are one of our biggest recurring problems, can you briefly document the expectations of the potential main culprits, such as this one? Or maybe, we can have some SOP or recommended usage in a more centralized location that explains what will and what will not trigger race conditions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My bad. There should be an await definitely.
I add this line before actually implement the function and forget to add the missing await after making it an async function.

@@ -8,4 +8,11 @@ export default class GlobalErrorsChildNode extends TraceNode {
buildChildren() {
return this.childTraces.map(t => this.treeNodeProvider.buildNode(TraceNode, t, this));
}

getSelectedChildren() {
Copy link
Owner

Choose a reason for hiding this comment

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

Should this function not be in TraceNode?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TraceNodes have their own isSelected method. getSelectedChildren is for their parent but not TraceNode themself.

@@ -33,6 +36,12 @@ export default class GlobalErrorsNode extends BaseTreeViewNode {
return child;
}
}
for (const child of this.children) {
Copy link
Owner

Choose a reason for hiding this comment

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

can use this.children.find instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cannot simply use find since it is a flatFind(or findMap) operation.


class SearchController {
constructor() {
this._emitter = new NanoEvents();
Copy link
Owner

Choose a reason for hiding this comment

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

Since this is a singleton, have you made sure that it gets reset when it is invalidated?
Specifically: this stores matches, contexts etc. When their application is deselected/removed, are you making sure that those invalid data points are not lingering?
Can you add at least part of the reset mechanic as a method to this class, so we can easily find where it happens, when necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Solution: re-search every time ApplicationSelectionChanged.

},

findContextsByTraceSearchTerm(dp, searchTerm) {
searchTraces(dp, searchTerm) {
Copy link
Owner

Choose a reason for hiding this comment

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

A bit of clean up - can you:

  • move all search-related functions together
  • rename find to search
  • add a comment-barrier-1: "search" to mark the whole region

?

@@ -82,28 +66,23 @@ export default class ContextNodeManager extends HostComponentEndpoint {
}

// TODO: makeDebounce
refreshOnData = () => {
refreshOnData = async () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Does this not need a makeDebounce?


// propagate mode to sub graph
const childMode = this.getChildMode();
for (const child of this.owner.children) {
if (!hasGraphNode(child)) {
this.logger.warn(`GraphNode owner's children contains no graphNode`);
this.logger.warn(`GraphNode owner's children ${child.debugTag} contains no graphNode`);
Copy link
Owner

@Domiii Domiii Jan 23, 2022

Choose a reason for hiding this comment

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

This warning message is better, but still not very helpful to a dev who does not currently work on this exact feature. Usually, you want to add a bit more context information: at least we usually want to add which function/operation/feature caused this.

@Domiii Domiii merged commit acd7622 into master Jan 23, 2022
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