Skip to content

Commit e2e534c

Browse files
author
Daniel Arrizza
committed
add AS
1 parent 9b596da commit e2e534c

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ Create AppD dashboards at lightning speed with a query language
1212
## Development
1313

1414
### Features
15+
- [x] shortforms: (art = Average Response Time (ms), etc.)
1516
- [x] headers
1617
- [x] default metric format strings
18+
- [x] AS
1719
- [] add a title
1820
- [] more than just bts
1921
- [] WHERE on a name/label
2022
- [] WHERE operators (>, <, REGEX, etc.)
2123
- [] WHERE on metric values (current art > x)
22-
- [] AS
2324
- [] SORT BY
2425
- [] LIMIT
2526
- [] query autocomplete
@@ -29,7 +30,6 @@ Create AppD dashboards at lightning speed with a query language
2930
- [] create multiple dashboards at once
3031
- [] save queries
3132
- [] more metric types: browser, mobile, DB, SIM
32-
- [] shortforms: (art = Average Response Time (ms), etc.)
3333
- [] styling/theming
3434
- [] add logo
3535
- [] table grid lines

src/getColumnFromSelect.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const LABEL_ENTITIES = ['bt', 'tier', 'backend']
1212
export default ({
1313
selects, selectIndex, data, wheres,
1414
}) => {
15-
const select = selects[selectIndex]
15+
const select = selects[selectIndex].value
1616
const header = createHeader({
17-
labelText: getMetricFromShortcut(select).metric,
17+
labelText: selects[selectIndex].as || getMetricFromShortcut(select).metric,
1818
x: selectIndex,
1919
})
2020

@@ -35,7 +35,7 @@ export default ({
3535

3636
const applicationName = getApplicationFromWheres({ wheres })
3737
const { metric } = getMetricFromShortcut(select)
38-
if (selects[0] === 'bt') {
38+
if (selects[0].value === 'bt') {
3939
const metricWidgetData = data.bt.map(({ internalName, tierName }) => ({
4040
applicationName,
4141
metricPath: `Business Transaction Performance|Business Transactions|${tierName}|${internalName}|${metric}`,

src/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import createDashboard from './createDashboard'
77

88
const main = async () => {
99
const DASHBOARD_NAME = 'z_dan_2'
10-
const query = 'SELECT bt, art, cpm, epm FROM applications WHERE application = "2075ICE.PREPROD"'
10+
const query = 'SELECT bt, art AS "Response Time", cpm, epm FROM applications WHERE application = "2075ICE.PREPROD"'
1111

1212
const { selects, from, wheres } = queryParser({ query })
1313

src/queryParser.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ const getSelects = ({ query }) => {
44
const selectRegex = /select(.*)from/i
55
const allSelect = selectRegex.exec(query)
66
const selects = allSelect[1].split(',').map(s => s.trim())
7-
return selects
7+
const selectsWithAs = selects.map(select => {
8+
const asRegex = /(.*) as (.*)/i
9+
const asResults = asRegex.exec(select)
10+
if (asResults) {
11+
return {
12+
value: asResults[1],
13+
as: asResults[2].substr(1, asResults[2].length - 2),
14+
}
15+
} else {
16+
return { value: select }
17+
}
18+
})
19+
return selectsWithAs
820
}
921

1022
const getFrom = ({ query }) => {

0 commit comments

Comments
 (0)