-
Notifications
You must be signed in to change notification settings - Fork 23
Combine desktop and mobile for "Missing one" chart #1461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Combine desktop and mobile for "Missing one" chart #1461
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is in draft. But I wanted to give some early feedback while I had a chance.
backend/pkg/httpserver/list_missing_one_implementation_counts.go
Outdated
Show resolved
Hide resolved
backend/pkg/httpserver/list_missing_one_implementation_counts_test.go
Outdated
Show resolved
Hide resolved
var targetBrowserFilter string | ||
if len(targetBrowsers) > 1 { | ||
targetBrowserFilter = fmt.Sprintf("(bfse.TargetBrowserName = '%s' OR bfse.TargetBrowserName = '%s')", | ||
targetBrowsers[0], targetBrowsers[1]) | ||
} else { | ||
targetBrowserFilter = fmt.Sprintf("bfse.TargetBrowserName = '%s'", targetBrowsers[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is necessarily the best way to generate these filters, but the inputs are sanitized, so this shouldn't cause any problem. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should continue to treat each input as user input and add them as spanner parameters to the params map like before.
conditions := make([]string, len(targetBrowsers))
for i, browserName := range targetBrowsers {
paramName := fmt.Sprintf("targetBrowserParam%d", i) // Create a unique param name, e.g., targetBrowserParam0
conditions[i] = fmt.Sprintf("bfse.TargetBrowserName = @%s", paramName)
params[paramName] = browserName // Add the actual browser name to the params map
}
targetBrowserFilter = fmt.Sprintf("(%s)", strings.Join(conditions, " OR "))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I thought we wanted the set of features that exist in both the desktop and mobile (vs either the desktop or mobile version). Would this current query do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to revisit handling N cases, you can file an issue and do that later. But we should use the param map now just to be safe.
var targetBrowserFilter string | ||
if len(targetBrowsers) > 1 { | ||
targetBrowserFilter = fmt.Sprintf("(bfse.TargetBrowserName = '%s' OR bfse.TargetBrowserName = '%s')", | ||
targetBrowsers[0], targetBrowsers[1]) | ||
} else { | ||
targetBrowserFilter = fmt.Sprintf("bfse.TargetBrowserName = '%s'", targetBrowsers[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should continue to treat each input as user input and add them as spanner parameters to the params map like before.
conditions := make([]string, len(targetBrowsers))
for i, browserName := range targetBrowsers {
paramName := fmt.Sprintf("targetBrowserParam%d", i) // Create a unique param name, e.g., targetBrowserParam0
conditions[i] = fmt.Sprintf("bfse.TargetBrowserName = @%s", paramName)
params[paramName] = browserName // Add the actual browser name to the params map
}
targetBrowserFilter = fmt.Sprintf("(%s)", strings.Join(conditions, " OR "))
var targetBrowserFilter string | ||
if len(targetBrowsers) > 1 { | ||
targetBrowserFilter = fmt.Sprintf("(bfse.TargetBrowserName = '%s' OR bfse.TargetBrowserName = '%s')", | ||
targetBrowsers[0], targetBrowsers[1]) | ||
} else { | ||
targetBrowserFilter = fmt.Sprintf("bfse.TargetBrowserName = '%s'", targetBrowsers[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I thought we wanted the set of features that exist in both the desktop and mobile (vs either the desktop or mobile version). Would this current query do that?
params["targetBrowserParam"] = targetBrowser | ||
otherBrowsersParamNames := make([]string, 0, len(otherBrowsers)) | ||
var targetBrowserFilter string | ||
if len(targetBrowsers) > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to the earlier comment about using the param map.
paramName := fmt.Sprintf("otherBrowser%d", i) | ||
params[paramName] = otherBrowsers[i] | ||
otherBrowsersParamNames = append(otherBrowsersParamNames, paramName) | ||
if len(otherBrowsers[i]) > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to the earlier comment about using the param map.
var targetBrowserFilter string | ||
if len(targetBrowsers) > 1 { | ||
targetBrowserFilter = fmt.Sprintf("(bfse.TargetBrowserName = '%s' OR bfse.TargetBrowserName = '%s')", | ||
targetBrowsers[0], targetBrowsers[1]) | ||
} else { | ||
targetBrowserFilter = fmt.Sprintf("bfse.TargetBrowserName = '%s'", targetBrowsers[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to revisit handling N cases, you can file an issue and do that later. But we should use the param map now just to be safe.
type mockDesktopMobileBrowserPair struct { | ||
Desktop string | ||
Mobile string | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type mockDesktopMobileBrowserPair struct { | |
Desktop string | |
Mobile string | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant to remove this.
14dcab6
to
a6427d6
Compare
`"endAt":"2000-01-10","include_baseline_mobile_browsers":true,` + | ||
`"browser":["chrome","firefox","safari"]}}`, | ||
Value: nil, | ||
Err: ErrNoMatchingMobileBrowser, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the error returned from the cache layer.
Err: ErrNoMatchingMobileBrowser, | |
Err: cachetypes.ErrCachedDataNotFound, |
mockConfig: &MockListMissingOneImplCountsConfig{ | ||
expectedTargetBrowsers: []string{"chrome"}, | ||
expectedOtherBrowsers: [][]string{ | ||
{"edge"}, | ||
{"firefox"}, | ||
{"safari"}, | ||
}, | ||
expectedStartAt: time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC), | ||
expectedEndAt: time.Date(2000, time.January, 10, 0, 0, 0, 0, time.UTC), | ||
expectedPageSize: 100, | ||
expectedPageToken: badPageToken, | ||
page: nil, | ||
pageToken: nil, | ||
err: backendtypes.ErrInvalidPageToken, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation logic should stop before the call to ListMissingOneImplCounts
mockConfig: &MockListMissingOneImplCountsConfig{ | |
expectedTargetBrowsers: []string{"chrome"}, | |
expectedOtherBrowsers: [][]string{ | |
{"edge"}, | |
{"firefox"}, | |
{"safari"}, | |
}, | |
expectedStartAt: time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC), | |
expectedEndAt: time.Date(2000, time.January, 10, 0, 0, 0, 0, time.UTC), | |
expectedPageSize: 100, | |
expectedPageToken: badPageToken, | |
page: nil, | |
pageToken: nil, | |
err: backendtypes.ErrInvalidPageToken, | |
}, | |
mockConfig: nil, |
|
||
targetBrowserConditions := make([]string, 0, len(targetBrowsers)) | ||
for i, browserName := range targetBrowsers { | ||
paramName := fmt.Sprintf("targetBrowserParam%d", i) // Create a unique param name, e.g., targetBrowserParam0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paramName := fmt.Sprintf("targetBrowserParam%d", i) // Create a unique param name, e.g., targetBrowserParam0 | |
paramName := fmt.Sprintf("targetBrowserParam%d", i) |
@@ -103,9 +104,9 @@ SELECT releases.EventReleaseDate, | |||
AND obsf.EventReleaseDate = tbuf.EventReleaseDate | |||
WHERE | |||
tbuf.EventReleaseDate = releases.EventReleaseDate | |||
{{ range $browserParamName := .OtherBrowsersParamNames }} | |||
{{ range $releaseDateFilter := .ReleaseDateFilters }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you talk a little bit about the need for the releaseDateFilter? I'm trying to understand why it is needed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reviewing the query again, I do not think this is needed, and I had mistakenly thought the browsers needed to be queried in their respective pairs here. I'm updating the code to reflect this change.
1cb07ff
to
8d703b8
Compare
This change updates the "missing one" API endpoints to accept a new query parameter which will allow desktop and mobile versions of the same browser to be treated as one entity.
This should have no change on the app's current behavior, as the request for the front-end has not yet been changed.