Skip to content

Commit

Permalink
QA: #4849 - UAT Feedback
Browse files Browse the repository at this point in the history
- Change the query to be more inclusive
- Use sub-queries for performance
- Start at 3 characters
- Don't show 'only' results to allow proper site navigation
  • Loading branch information
TheWitness committed Jul 6, 2022
1 parent 76456e6 commit 5f82d2d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
35 changes: 26 additions & 9 deletions graph_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,33 @@ function get_matching_nodes() {
FROM graph_tree_items AS gti
LEFT JOIN host AS h
ON h.id = gti.host_id
LEFT JOIN graph_templates_graph AS gtg
LEFT JOIN (
SELECT DISTINCT site_id
FROM host
WHERE description LIKE ?
OR hostname LIKE ?
) AS h2
ON h2.site_id = gti.site_id
LEFT JOIN (
SELECT local_graph_id
FROM graph_templates_graph
WHERE local_graph_id > 0
AND title_cache LIKE ?
) AS gtg
ON gtg.local_graph_id = gti.local_graph_id
LEFT JOIN sites AS s
ON s.id = h.site_id
WHERE (gtg.local_graph_id > 0 AND gtg.title_cache LIKE ?)
OR (h.description LIKE ? AND gti.host_id > 0)
OR (h.hostname LIKE ? AND gti.host_id > 0)
OR (gti.title LIKE ?)
OR (s.name LIKE ? AND gti.site_id > 0)",
array($filter, $filter, $filter, $filter, $filter));
LEFT JOIN (
SELECT id
FROM sites
WHERE name LIKE ?
) AS site
ON site.id = gti.site_id
WHERE (gti.title LIKE ?)
OR (h.description LIKE ? AND (gti.host_id > 0 OR gti.site_id > 0))
OR (h.hostname LIKE ? AND (gti.host_id > 0 OR gti.site_id > 0))
OR (h2.site_id > 0)
OR (gtg.local_graph_id > 0)
OR (site.id > 0)",
array($filter, $filter, $filter, $filter, $filter, $filter, $filter));
} else {
$matching = db_fetch_assoc("SELECT parent, graph_tree_id FROM graph_tree_items");
}
Expand Down
14 changes: 8 additions & 6 deletions lib/html_tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,19 @@ function openNodes() {
'dots' : false
},
'state' : { 'key' : 'graph_tree_history' },
'search' : { 'case_sensitive' : false, 'show_only_matches' : true, 'ajax' : { 'url' : urlPath+'graph_view.php?action=ajax_search'} },
'search' : { 'case_sensitive' : false, 'show_only_matches' : false, 'ajax' : { 'url' : urlPath+'graph_view.php?action=ajax_search'} },
'plugins' : [ 'types', 'state', 'wholerow', 'search' ]
});
});

$('#searcher').keyup(function() {
if(search_to) { clearTimeout(search_to); }
search_to = setTimeout(function() {
var v = $('#searcher').val();
$('#jstree').jstree('search', v, false);
}, 250);
if ($('#searcher').val().length >= 3) {
if(search_to) { clearTimeout(search_to); }
search_to = setTimeout(function() {
var v = $('#searcher').val();
$('#jstree').jstree('search', v, false);
}, 250);
}
});

<?php print api_plugin_hook_function('top_graph_jquery_function');?>
Expand Down

0 comments on commit 5f82d2d

Please sign in to comment.