Skip to content
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

"Simple" search support in aw_freeform_report #37

Open
gilliganondata opened this issue Nov 24, 2020 · 1 comment
Open

"Simple" search support in aw_freeform_report #37

gilliganondata opened this issue Nov 24, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@gilliganondata
Copy link
Collaborator

Add support for two "simple" use cases for the search argument in aw_freeform_report.

This is based on the premise that a common use case will be simply filtering for a single value.

Currently, to do the simplest of searches requires nesting a single quote within double quotes:

search = "'tablet'"

Add support for passing a simple string to search and then have that string be searched as a CONTAINS on the first dimension in the results:

So, search = "tablet" would actually execute search = "CONTAINS 'tablet'") (the CONTAINS isn't required in the API call, since that's the default).

Also, possibly (?) extend this support to a vector format if the user really wants a simple CONTAINS on multiple dimensions:

search = c("tablet", "search") would actually execute search = c("CONTAINS 'tablet'", "CONTAINS 'recliner'"))

@gilliganondata gilliganondata added the enhancement New feature or request label Nov 24, 2020
@charlie-gallagher
Copy link
Collaborator

I've thought about solutions to this myself. I wonder if it would be better to have a suite of functions that generate search strings instead?

It seems like it would be hard to know when we should modify the string and when we should leave it alone, especially for edge cases. But if we move the responsibility to the user, things get a lot simpler. Something like

s_simple("tablet")
# [1] "CONTAINS 'tablet'"
s_exact("tablet")
# [1] "MATCH 'tablet'"
s_begins_with("tab")
# [1] "BEGINS-WITH 'tab'"
s_any_exact(c("one", "two", "three"))
# [1] "(MATCH 'one') OR (MATCH 'two') OR (MATCH 'three')"

And so on, etc. Sure it lacks the brevity of search = "tablet", but it also lacks the ambiguity, and reduces user error significantly. Inline they're a little ugly, but also not the worst.

aw_freeform_table(
  dimensions = c("device", "page"),
  search = c(s_simple("tablet"), s_exact("/mypage.html"))
)

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

No branches or pull requests

2 participants