Skip to content

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

DanielRyanSmith
Copy link
Collaborator

@DanielRyanSmith DanielRyanSmith commented May 5, 2025

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.

Copy link
Collaborator

@jcscottiii jcscottiii left a 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.

@DanielRyanSmith DanielRyanSmith marked this pull request as ready for review May 6, 2025 19:54
Comment on lines 219 to 224
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])
Copy link
Collaborator Author

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. 😅

Copy link
Collaborator

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 "))

Copy link
Collaborator

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?

Copy link
Collaborator

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.

Comment on lines 219 to 224
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])
Copy link
Collaborator

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 "))

Comment on lines 219 to 224
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])
Copy link
Collaborator

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 {
Copy link
Collaborator

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 {
Copy link
Collaborator

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.

Comment on lines 219 to 224
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])
Copy link
Collaborator

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.

Comment on lines 128 to 132
type mockDesktopMobileBrowserPair struct {
Desktop string
Mobile string
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type mockDesktopMobileBrowserPair struct {
Desktop string
Mobile string
}

Copy link
Collaborator

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.

`"endAt":"2000-01-10","include_baseline_mobile_browsers":true,` +
`"browser":["chrome","firefox","safari"]}}`,
Value: nil,
Err: ErrNoMatchingMobileBrowser,
Copy link
Collaborator

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.

Suggested change
Err: ErrNoMatchingMobileBrowser,
Err: cachetypes.ErrCachedDataNotFound,

Comment on lines 329 to 343
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,
},
Copy link
Collaborator

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

Suggested change
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 }}
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants