Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
cda3b017
Commit
cda3b017
authored
Aug 03, 2018
by
David Kaltschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reversed history direction for explore
- _.reverse() was modifying state.history
parent
eaff7b0f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
5 deletions
+4
-5
public/app/containers/Explore/Explore.tsx
+2
-2
public/app/containers/Explore/PromQueryField.tsx
+2
-3
No files found.
public/app/containers/Explore/Explore.tsx
View file @
cda3b017
...
...
@@ -289,10 +289,10 @@ export class Explore extends React.Component<any, IExploreState> {
const
ts
=
Date
.
now
();
queries
.
forEach
(
q
=>
{
const
{
query
}
=
q
;
history
=
[
...
history
,
{
query
,
ts
}
];
history
=
[
{
query
,
ts
},
...
history
];
});
if
(
history
.
length
>
MAX_HISTORY_ITEMS
)
{
history
=
history
.
slice
(
history
.
length
-
MAX_HISTORY_ITEMS
);
history
=
history
.
slice
(
0
,
MAX_HISTORY_ITEMS
);
}
// Combine all queries of a datasource type into one history
const
historyKey
=
`grafana.explore.history.
${
datasourceId
}
`
;
...
...
public/app/containers/Explore/PromQueryField.tsx
View file @
cda3b017
...
...
@@ -35,7 +35,7 @@ export function addHistoryMetadata(item: Suggestion, history: any[]): Suggestion
const
cutoffTs
=
Date
.
now
()
-
HISTORY_COUNT_CUTOFF
;
const
historyForItem
=
history
.
filter
(
h
=>
h
.
ts
>
cutoffTs
&&
h
.
query
===
item
.
label
);
const
count
=
historyForItem
.
length
;
const
recent
=
historyForItem
.
pop
()
;
const
recent
=
historyForItem
[
0
]
;
let
hint
=
`Queried
${
count
}
times in the last 24h.`
;
if
(
recent
)
{
const
lastQueried
=
moment
(
recent
.
ts
).
fromNow
();
...
...
@@ -189,11 +189,10 @@ class PromQueryField extends React.Component<PromQueryFieldProps, PromQueryField
if
(
history
&&
history
.
length
>
0
)
{
const
historyItems
=
_
.
chain
(
history
)
.
uniqBy
(
'query'
)
.
take
Right
(
HISTORY_ITEM_COUNT
)
.
take
(
HISTORY_ITEM_COUNT
)
.
map
(
h
=>
h
.
query
)
.
map
(
wrapLabel
)
.
map
(
item
=>
addHistoryMetadata
(
item
,
history
))
.
reverse
()
.
value
();
suggestions
.
push
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment