Comments (6)
maybe my first tests were wrong, I've emulated this behavior this way
filters :days_since_last_visit.eql => 7
filters :days_since_last_visit.eql => 6
filters :days_since_last_visit.eql => 5
filters :days_since_last_visit.eql => 4
filters :days_since_last_visit.eql => 3
filters :days_since_last_visit.eql => 2
filters :days_since_last_visit.eql => 1
filters :days_since_last_visit.eql => 0
from garb.
I'm not certain what they net effect of all this is. Either way, your comment is correct. You can re-use the filters method and it will OR them together (because you can't have something that is both 5 AND 6 days since last visit).
A shorthand for this my be:
filters *([1..7].map { |i| {:days_since_last_visit.eql => i} })
from garb.
Just to clarify, that code creates an array of hashes containing the filter on days_since_last_visit equal to each day, and then unpacks it for passage to filters.
from garb.
The reason the first example did not work was because filters within one block will be AND'd together, and you can't have a metric/dimension as a filter that is two things at once.
This also occurs practically from the use of hashes. You can use the same metric with two distinct symbol operators (>= and <= on the same metric).
from garb.
the shorthand in your first comment is absolutely what I was going for. Digging into the garb code I recognized quickly that you were storing a list of hashes (not just a hash), but the methods of manipulating that were rather opaque.
At first I thought that the choice of a hash as the containing data structure was just flawed, and that it would be better implemented as a list where insertion offered an api to limit duplicates. But I think that the list of hashes is actually pretty solid, but that the current api makes it... unclear which of the two effects you're creating are. Are you adding the hash to a list... or are you adding an element to the hash...
Anyway... thanks for the prompt response, I'd call this closed :)
from garb.
You're welcome.
I've only just recently clarified the AND/OR behavior and reconciled with the GA api docs. This is still a work-in-progress.
from garb.
Related Issues (20)
- Are there plans to implement the new Core Reporting API?
- account.profiles seems to be returning a "invalidRequestUri" HOT 2
- Garb is not working - v2.3 was shutdown HOT 9
- Access via Simple API Access Key HOT 2
- Bug with filters OR HOT 3
- Issue with GA pulling data falling over leap day HOT 1
- Requesting list of segments raises TypeError exception HOT 1
- 404 on the README HOT 1
- undefined method `contains' for :page_path:Symbol HOT 3
- Using multiple filters doesn't work as expected HOT 2
- Syntax for the Segments HOT 1
- Metric collection
- Garb::Request::Authentication::AuthError
- Link to Google Analytics API
- Unable to authenticate with simple login(?) HOT 19
- Analytics API deprecated (?) HOT 1
- Conflict with right_http_connection gem
- Getting "Requested 15 dimensions; only 7 are allowed." often
- Garb fails in Ruby 1.9.3 p392 because of REXML patch HOT 4
- Garb::Management::Account#profiles results in a Garb::DataRequest::ClientError with message "Not Found"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from garb.