Skip to content

Commit

Permalink
Merge pull request #23 from tzellman/master
Browse files Browse the repository at this point in the history
Added ability to pass the 'bucket' parameter, for counts queries
  • Loading branch information
dirkbonhomme committed Jun 28, 2017
2 parents 406e899 + b106ea7 commit ea82e56
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ The maximum number of search results to be returned by a request. A number betwe
#### options.tag
Used to segregate rules and their matching data into different logical groups. Optional.

#### options.bucket
The unit of time for which count data will be provided. Options: "day", "hour", "minute". Optional, for /counts calls.

## API methods

#### stream.start()
Expand Down Expand Up @@ -234,4 +237,18 @@ Example Usage
console.error(err);
});

// search counts usage
var counts = new Gnip.Search({
url : 'https://gnip-stream.twitter.com/stream/powertrack/accounts/xxx/publishers/twitter/prod/counts.json',
user : 'xxx',
password : 'xxx',
query : '@user',
bucket: 'day'
});

counts.on('object', function(object) {
console.log(object.results);
counts.end();
});

More details and tests soon...
3 changes: 3 additions & 0 deletions lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ GnipSearch.prototype._makeRequest = function( next, callback )
if( this.options.tag )
requestParameters.tag = this.options.tag;

if( this.options.bucket )
requestParameters.bucket = this.options.bucket.toLowerCase();

if( next )
requestParameters.next = next;

Expand Down

0 comments on commit ea82e56

Please sign in to comment.