Skip to content

Instantly share code, notes, and snippets.

@joelr
Last active October 19, 2015 23:07
Show Gist options
  • Save joelr/1ab6e4b984de8f64c103 to your computer and use it in GitHub Desktop.
Save joelr/1ab6e4b984de8f64c103 to your computer and use it in GitHub Desktop.
LB example.md

sort_by=calories&group_by=team&filter[campaign]=au-123,au-456&filter[date_start]=2015-01-01&filter[date_end]=2015-01-01 This should group by team_page_id on the document

[
   {
     team: {
       name: 'Team abc',
       url: 'http://def',
       team_page_id: 123,
     },
     calories: 12345, (calories)
     doc_count: 50,  (number of activities),
     elevation: 4567, (meters)
     distance: 1234, (meters)
     time: 12345,  (seconds)
    },
   {
     team: {
       name: 'Team hello',
       url: 'http://hi',
       team_page_id: 1234,
     },
     calories: 12345,
     doc_count: 50, 
     elevation: 4567,
     distance: 1234,
     time: 12345
    },
   {
     team: {
       name: 'Team 123456',
       url: 'http://hi there',
       team_page_id: 1234,
     },
     calories: 12345,
     doc_count: 50, 
     elevation: 4567,
     distance: 1234,
     time: 12345
    }
  ]

sort_by=calories&group_by=page&filter[team_page_id]=456&filter[campaign]=au-123,au-456&filter[date_start]=2015-01-01&filter[date_end]=2015-01-01

This should group by page_id on the document. in this case we're filtering to a specific team. It should filter to activities with team_page_id=456

[
   {
     page: {
       name: 'My abc',
       url: 'http://def',
       id: 123
     },
     calories: 12345, (calories)
     doc_count: 50,  (number of activities),
     elevation: 4567, (meters)
     distance: 1234, (meters)
     time: 12345,  (seconds)
    },
   {
     page: {
       name: 'Page hello',
       url: 'http://hi',
       id: 456
     },
     calories: 12345,
     doc_count: 50, 
     elevation: 4567,
     distance: 1234,
     time: 12345
    },
   {
     page: {
       name: 'Page 123456',
       url: 'http://hi there',
       id: 123
     },
     calories: 12345,
     doc_count: 50, 
     elevation: 4567,
     distance: 1234,
     time: 12345
    }
  ]
@langsharpe
Copy link

{
  results: [
    {
     page: {
       name: 'My abc',
       url: 'http://def',
       id: 123
     },
     calories: 12345, (calories)
     count: 50,  (number of activities),
     elevation_in_meters: 4567, (meters)
     distance_in_meters: 1234, (meters)
     duration_in_seconds: 12345,  (seconds)
    },
    {
     page: {
       name: 'Page hello',
       url: 'http://hi',
       id: 456
     },
     calories: 12345,
     count: 50,
     elevation_in_meters: 4567,
     distance_in_meters: 1234,
     duration_in_seconds: 12345
    },
    {
     page: {
       name: 'Page 123456',
       url: 'http://hi there',
       id: 123
     },
     calories: 12345,
     count: 50,
     elevation_in_meters: 4567,
     distance_in_meters: 1234,
     duration_in_seconds: 12345
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment