Add pretty-printing option for query results - #4
Merged
Conversation
Use --pretty to enable this feature. This will likely break on non-ANSI terminals.
chiiph
pushed a commit
that referenced
this pull request
Aug 4, 2021
5 tasks
10 tasks
2 tasks
57 tasks
6 tasks
getvictor
added a commit
that referenced
this pull request
Apr 6, 2026
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #42836 This is another hot path optimization. ## Before When a host submits policy results via `SubmitDistributedQueryResults`, the system needed to determine which policies "flipped" (changed from passing to failing or vice versa). Each consumer computed this independently: ``` SubmitDistributedQueryResults(policyResults) | +-- processScriptsForNewlyFailingPolicies | filter to failing policies with scripts | BUILD SUBSET of results | CALL FlippingPoliciesForHost(subset) <-- DB query #1 | convert result to set, filter, queue scripts | +-- processSoftwareForNewlyFailingPolicies | filter to failing policies with installers | BUILD SUBSET of results | CALL FlippingPoliciesForHost(subset) <-- DB query #2 | convert result to set, filter, queue installs | +-- processVPPForNewlyFailingPolicies | filter to failing policies with VPP apps | BUILD SUBSET of results | CALL FlippingPoliciesForHost(subset) <-- DB query #3 | convert result to set, filter, queue VPP | +-- webhook filtering | filter to webhook-enabled policies | CALL FlippingPoliciesForHost(subset) <-- DB query #4 | register flipped policies in Redis | +-- RecordPolicyQueryExecutions CALL FlippingPoliciesForHost(all results) <-- DB query #5 reset attempt counters for newly passing INSERT/UPDATE policy_membership ``` Each `FlippingPoliciesForHost` call runs `SELECT policy_id, passes FROM policy_membership WHERE host_id = ? AND policy_id IN (?)`. All 5 queries hit the same table for the same host before `policy_membership` is updated, so they all see identical state. Each consumer also built intermediate maps to narrow down to its subset before calling `FlippingPoliciesForHost`, then converted the result into yet another set for filtering. This meant 3-4 temporary maps per consumer. ## After ``` SubmitDistributedQueryResults(policyResults) | CALL FlippingPoliciesForHost(all results) <-- single DB query build newFailingSet, normalize newPassing | +-- processScriptsForNewlyFailingPolicies | filter to failing policies with scripts | CHECK newFailingSet (in-memory map lookup) | queue scripts | +-- processSoftwareForNewlyFailingPolicies | filter to failing policies with installers | CHECK newFailingSet (in-memory map lookup) | queue installs | +-- processVPPForNewlyFailingPolicies | filter to failing policies with VPP apps | CHECK newFailingSet (in-memory map lookup) | queue VPP | +-- webhook filtering | filter to webhook-enabled policies | FILTER newFailing/newPassing by policy IDs (in-memory) | register flipped policies in Redis | +-- RecordPolicyQueryExecutions USE pre-computed newPassing (skip DB query) reset attempt counters for newly passing INSERT/UPDATE policy_membership ``` The intermediate subset maps and per-consumer set conversions are removed. Each process function goes directly from "policies with associated automation" to "is this policy in newFailingSet?" in a single map lookup. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Performance Improvements** * Reduced redundant database queries during policy result submissions by computing flipping policies once per host check-in instead of multiple times. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
4 tasks
2 tasks
11 tasks
10 tasks
2 tasks
1 task
RachelElysia
added a commit
that referenced
this pull request
Jul 21, 2026
- (#1) Swap useEffect/[showSearch] focus for native autoFocus on the search input. react-select unmounts <Menu> on close, so the input is a fresh DOM node on each open — autoFocus fires reliably without depending on effect deps semantics. - (#2) Key CustomMenuList's useLayoutEffect on React.Children.count(...) so it only re-measures scroll dimensions when the option list actually changes (search filter shrink/expand). onScroll still covers user- driven position changes. - (#3) menu.zIndex 6 -> 99 (page-overlay tier), __scroll-fade z-index 1 -> 9 (in-flow overlay tier), matching the 9/99/999 convention. - (#4) Add optional onAddFleet callback prop. If provided, fires instead of the browserHistory.push fallback — lets consumers use their own router.push. Nine current callers unaffected. - (#8) TODOL -> TODO: typo in the tests file (inherited from the deleted TeamsDropdown.tests.tsx).
RachelElysia
added a commit
that referenced
this pull request
Jul 21, 2026
- (#4) Deep dive: drop the optional onAddFleet prop entirely rather than carrying a dead migration path. `browserHistory` is fine in frontend/components/ (used by AuthenticationNav and CommandPalette), so the fallback becomes the sole path — no dead code, no half-wired interface. Consumers that ever need to override navigation can add the prop back at that point. - (#5) Add `aria-label="Search fleets"` to the search input — screen readers skip placeholder-as-label once the field has a value. - (#6) Drop `name="fleet-search-input"` (not a form-submitted field) and add `autoComplete="off"` so browsers don't pop autofill suggestions on top of the option list. - (#7) Rename `TeamsDropdown` -> `FleetsDropdown` in frontend/docs/patterns.md:459 (Fleet switcher reference). - (#8) Use getPathWithQueryParams(PATHS.ADMIN_FLEETS, { create_fleet: "1" }) instead of the plain template string — matches the codebase's URL-construction convention.
RachelElysia
added a commit
that referenced
this pull request
Jul 22, 2026
- (#1) preventDefault on Enter in addFleetKeyDown. Fleet Button's own handleKeyDown synthesizes onClick from Enter, so without preventDefault the browser ALSO synthesizes a native click after keyup, firing onClickAddFleet a second time. jsdom didn't catch this (it doesn't synthesize click from keyDown); the double-fire only manifests in a real browser. Space is left with stopPropagation only — Fleet Button has no Space handler, and native click synthesis is Space's only activation path. - (#2) Dev-only console.warn in getHiddenInput() when SelectInstance.inputRef is unexpectedly missing. Surfaces a react-select upgrade breaking the keydown-forwarding bridge loudly in dev instead of silently regressing keyboard nav. - (#4) Consolidate searchQuery clearing into the menuIsOpen transition effect. The same setSearchQuery("") was duplicated at 5 close origins (click-outside, toggleMenu, handleChange, onClickAddFleet, onMenuClose). All 5 removed; the transition effect is now the single source of truth for close-side state cleanup. - (#6) Story decorator: height: 600 -> minHeight: 780. The old fixed height clipped scrollable-list stories when the open menu grew past 600px; minHeight 780 (menu maxHeight 715 + trigger + margin) lets the full menu render without clipping.
2 tasks
RachelElysia
added a commit
that referenced
this pull request
Jul 29, 2026
- (#3) Deleted orphaned components/UploadListHeading/ folder — no external importers left after the tab-header refactor. - (#4) ConfigurationProfiles: hide the __tab-header (description + Add button) when !mdmEnabled so the "Create and upload configuration profiles..." copy no longer contradicts the "MDM must be turned on" EmptyState directly below. - (#5) Extracted the duplicated __tab-header block into a @mixin tab-header in styles/var/mixins.scss; six copies across five files now @include it. - (#6) Comment on .profiles-tab explaining why ConfigurationProfiles splits its card wrapper from its per-tab layout (two inner tabs mirroring .assets-tab) while Certificates / ScriptLibrary stay single-block (one-tab card). - (#7) Comment on <span className="controls"> in TableContainer.tsx flagging the load-bearing shape that _styles.scss's :has(.controls > *) collapse rule depends on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use --pretty to enable this feature.
This will likely break on non-ANSI terminals.