Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
ebbaa093
Commit
ebbaa093
authored
9 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
finish cleaning up aggregation clause handling.
parent
dbcafdd3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
resources/frontend_client/app/query_builder/gui_query_editor.react.js
+30
-39
30 additions, 39 deletions
...ontend_client/app/query_builder/gui_query_editor.react.js
with
30 additions
and
39 deletions
resources/frontend_client/app/query_builder/gui_query_editor.react.js
+
30
−
39
View file @
ebbaa093
...
...
@@ -9,12 +9,11 @@ var GuiQueryEditor = React.createClass({
databases
:
React
.
PropTypes
.
array
.
isRequired
,
query
:
React
.
PropTypes
.
object
.
isRequired
,
defaultQuery
:
React
.
PropTypes
.
object
.
isRequired
,
isRunning
:
React
.
PropTypes
.
bool
.
isRequired
,
getTablesFn
:
React
.
PropTypes
.
func
.
isRequired
,
getTableDetailsFn
:
React
.
PropTypes
.
func
.
isRequired
,
runFn
:
React
.
PropTypes
.
func
.
isRequired
,
notifyQueryModifiedFn
:
React
.
PropTypes
.
func
.
isRequired
,
isRunning
:
React
.
PropTypes
.
bool
notifyQueryModifiedFn
:
React
.
PropTypes
.
func
.
isRequired
},
getInitialState
:
function
()
{
return
{
...
...
@@ -61,10 +60,6 @@ var GuiQueryEditor = React.createClass({
component
.
setState
({
options
:
updatedTable
});
if
(
component
.
props
.
query
.
query
.
aggregation
.
length
>
1
)
{
component
.
getAggregationFields
(
component
.
props
.
query
.
query
.
aggregation
[
0
]);
}
},
function
(
error
)
{
console
.
log
(
'
error getting table metadata
'
,
error
);
});
...
...
@@ -73,6 +68,7 @@ var GuiQueryEditor = React.createClass({
// check if this is the same db or not
if
(
databaseId
!==
this
.
props
.
query
.
database
)
{
// reset to a brand new query
// TODO: clone?
var
query
=
this
.
props
.
defaultQuery
;
// set our new database on the query
...
...
@@ -98,6 +94,13 @@ var GuiQueryEditor = React.createClass({
this
.
setQuery
(
query
,
true
);
},
canRun
:
function
()
{
var
canRun
=
false
;
if
(
this
.
aggregationComplete
())
{
canRun
=
true
;
}
return
canRun
;
},
runQuery
:
function
()
{
// ewwwww. we should do something better here
var
cleanQuery
=
this
.
cleanFilters
(
this
.
props
.
query
);
...
...
@@ -137,37 +140,32 @@ var GuiQueryEditor = React.createClass({
return
aggregationComplete
;
},
getAggregationFields
:
function
(
aggregation
)
{
// TODO: why does this mutate the query?
// todo - this could be a war crime
var
component
=
this
;
var
query
=
this
.
props
.
query
;
_
.
map
(
this
.
state
.
options
.
aggregation_options
,
function
(
option
)
{
for
(
var
i
=
0
;
i
<
this
.
state
.
options
.
aggregation_options
.
length
;
i
++
)
{
var
option
=
this
.
state
.
options
.
aggregation_options
[
i
];
if
(
option
.
short
===
aggregation
)
{
if
(
option
.
fields
.
length
>
0
)
{
if
(
query
.
query
.
aggregation
.
length
==
1
)
{
query
.
query
.
aggregation
[
1
]
=
null
;
}
component
.
setState
({
aggregation_field_list
:
option
.
fields
});
}
else
{
query
.
query
.
aggregation
.
splice
(
1
,
1
);
}
// not exactly sure why we need the first element instead of option.fields??
return
option
.
fields
[
0
];
}
});
this
.
setQuery
(
query
,
true
);
}
},
setAggregation
:
function
(
aggregation
)
{
var
query
=
this
.
props
.
query
;
query
.
query
.
a
ggregation
[
0
]
=
aggregation
;
var
query
=
this
.
props
.
query
,
query
A
ggregation
=
[
aggregation
]
;
this
.
setQuery
(
query
,
true
);
query
.
query
.
aggregation
=
queryAggregation
;
// check to see if this aggregation type requires another choice
_
.
map
(
this
.
state
.
options
.
aggregation_options
,
function
(
option
)
{
if
(
option
.
short
===
aggregation
&&
option
.
fields
.
length
>
0
)
{
// extend aggregation array by 1
queryAggregation
[
1
]
=
null
;
}
});
// if our aggregation requires selecting another part (e.g. sum of <field>)
// then lets make sure we've determined what those options should be
this
.
getAggregationFields
(
aggregation
);
this
.
setQuery
(
query
,
true
);
},
setAggregationTarget
:
function
(
target
)
{
var
query
=
this
.
props
.
query
;
...
...
@@ -250,13 +248,6 @@ var GuiQueryEditor = React.createClass({
}
return
dataset_query
;
},
canRun
:
function
()
{
var
canRun
=
false
;
if
(
this
.
aggregationComplete
())
{
canRun
=
true
;
}
return
canRun
;
},
_getFilterFields
:
function
()
{
var
filterFieldList
=
[];
if
(
this
.
state
.
options
)
{
...
...
@@ -406,7 +397,7 @@ var GuiQueryEditor = React.createClass({
aggregationTargetHtml
=
(
<
SelectionModule
placeholder
=
'
field named...
'
items
=
{
this
.
state
.
a
ggregation
_f
ield
_list
}
items
=
{
this
.
getA
ggregation
F
ield
s
(
this
.
props
.
query
.
query
.
aggregation
[
0
])
}
display
=
'
1
'
selectedValue
=
{
this
.
props
.
query
.
query
.
aggregation
[
1
]}
selectedKey
=
'
0
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment