feat(product_analytics): table of cards testing fitlers
This commit is contained in:
parent
96b5e2e0cc
commit
d2b455dfdb
2 changed files with 31 additions and 12 deletions
|
|
@ -51,6 +51,7 @@ var propertySelectorMap = map[string]string{
|
||||||
var mainColumns = map[string]string{
|
var mainColumns = map[string]string{
|
||||||
"userBrowser": "$browser",
|
"userBrowser": "$browser",
|
||||||
"referrer": "$referrer",
|
"referrer": "$referrer",
|
||||||
|
"ISSUE": "issue_type",
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t TableQueryBuilder) Execute(p Payload, conn db.Connector) (interface{}, error) {
|
func (t TableQueryBuilder) Execute(p Payload, conn db.Connector) (interface{}, error) {
|
||||||
|
|
@ -134,9 +135,20 @@ func (t TableQueryBuilder) buildQuery(r Payload, metricFormat string) (string, e
|
||||||
originalMetricOf := r.MetricOf
|
originalMetricOf := r.MetricOf
|
||||||
propertyName = originalMetricOf
|
propertyName = originalMetricOf
|
||||||
|
|
||||||
durationConds, eventFilters := buildDurationWhere(s.Filter.Filters)
|
durationConds, _ := buildDurationWhere(s.Filter.Filters)
|
||||||
|
eventFilters, _ := filterOutTypes(s.Filter.Filters, []FilterType{FilterDuration, FilterUserId})
|
||||||
|
_, sessionFilters := filterOutTypes(s.Filter.Filters, []FilterType{FilterUserId, FilterUserAnonymousId})
|
||||||
|
|
||||||
|
sessionConds, _ := buildEventConditions(sessionFilters, BuildConditionsOptions{
|
||||||
|
DefinedColumns: map[string]string{
|
||||||
|
"userId": "user_id",
|
||||||
|
},
|
||||||
|
MainTableAlias: "sessions",
|
||||||
|
})
|
||||||
|
|
||||||
eventConds, eventNames := buildEventConditions(eventFilters, BuildConditionsOptions{
|
eventConds, eventNames := buildEventConditions(eventFilters, BuildConditionsOptions{
|
||||||
DefinedColumns: mainColumns,
|
DefinedColumns: mainColumns,
|
||||||
|
MainTableAlias: "main",
|
||||||
})
|
})
|
||||||
baseWhereConditions := []string{
|
baseWhereConditions := []string{
|
||||||
fmt.Sprintf("main.created_at >= toDateTime(%d/1000)", r.StartTimestamp),
|
fmt.Sprintf("main.created_at >= toDateTime(%d/1000)", r.StartTimestamp),
|
||||||
|
|
@ -149,17 +161,7 @@ func (t TableQueryBuilder) buildQuery(r Payload, metricFormat string) (string, e
|
||||||
baseWhereConditions = append(baseWhereConditions, cond)
|
baseWhereConditions = append(baseWhereConditions, cond)
|
||||||
}
|
}
|
||||||
|
|
||||||
//baseWhereConditions := []string{
|
baseWhereConditions = append(baseWhereConditions, sessionConds...)
|
||||||
// fmt.Sprintf("main.created_at >= toDateTime(%d/1000)", r.StartTimestamp),
|
|
||||||
// fmt.Sprintf("main.created_at <= toDateTime(%d/1000)", r.EndTimestamp),
|
|
||||||
// "sessions.duration > 0",
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//if r.ProjectId > 0 {
|
|
||||||
// baseWhereConditions = append(baseWhereConditions, fmt.Sprintf("main.project_id = %d", r.ProjectId))
|
|
||||||
//}
|
|
||||||
|
|
||||||
var aggregationExpression string
|
var aggregationExpression string
|
||||||
var aggregationAlias = "aggregation_id"
|
var aggregationAlias = "aggregation_id"
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,12 @@ type BuildConditionsOptions struct {
|
||||||
var propertyKeyMap = map[string]filterConfig{
|
var propertyKeyMap = map[string]filterConfig{
|
||||||
"LOCATION": {LogicalProperty: "url_path"},
|
"LOCATION": {LogicalProperty: "url_path"},
|
||||||
"FETCH": {LogicalProperty: "url_path"},
|
"FETCH": {LogicalProperty: "url_path"},
|
||||||
|
"REQUEST": {LogicalProperty: "url_path"},
|
||||||
"CLICK": {LogicalProperty: "label"},
|
"CLICK": {LogicalProperty: "label"},
|
||||||
"INPUT": {LogicalProperty: "label"},
|
"INPUT": {LogicalProperty: "label"},
|
||||||
"fetchUrl": {LogicalProperty: "url_path"},
|
"fetchUrl": {LogicalProperty: "url_path"},
|
||||||
"fetchStatusCode": {LogicalProperty: "status", IsNumeric: true},
|
"fetchStatusCode": {LogicalProperty: "status", IsNumeric: true},
|
||||||
|
//"ISSUE": {LogicalProperty: "issue_type"},
|
||||||
// TODO add more mappings as needed
|
// TODO add more mappings as needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -466,3 +468,18 @@ func buildDurationWhere(filters []Filter) ([]string, []Filter) {
|
||||||
}
|
}
|
||||||
return conds, rest
|
return conds, rest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func filterOutTypes(filters []Filter, typesToRemove []FilterType) (kept []Filter, removed []Filter) {
|
||||||
|
removeMap := make(map[FilterType]struct{}, len(typesToRemove))
|
||||||
|
for _, t := range typesToRemove {
|
||||||
|
removeMap[t] = struct{}{}
|
||||||
|
}
|
||||||
|
for _, f := range filters {
|
||||||
|
if _, ok := removeMap[f.Type]; ok {
|
||||||
|
removed = append(removed, f)
|
||||||
|
} else {
|
||||||
|
kept = append(kept, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue