Skip to content

Instantly share code, notes, and snippets.

@wheresrhys
Last active January 25, 2016 16:07
Show Gist options
  • Select an option

  • Save wheresrhys/1b83050c625fd203aa57 to your computer and use it in GitHub Desktop.

Select an option

Save wheresrhys/1b83050c625fd203aa57 to your computer and use it in GitHub Desktop.
keen-query data structure

KeenQuery.wrapData(opts)

Properties of opts

name

Name to give the query. If listed in the alias spreadsheet this will be read from there

interval

For the purposes of formatting dates it's useful to say what the interval bewteen the data points is (e.g. minute, day). Not essential

metric

Name for what the values mean e.g. count, average

axes

An array defining the axes of the table. Each item in the array defines an entire axis

e.g

	[
		{
			name: 'page.location.search',
			values: ['apples', 'pears']
		},
		{
			name: 'timeframe',
			values: [
				{
					start: 'an ISO string',
					end: 'an ISO string'
				},
				{
					start: 'an ISO string',
					end: 'an ISO string'
				},
				{
					start: 'an ISO string',
					end: 'an ISO string'
				}
			]
		}
	]

dataStructure

How the data is organised. Default 'nested'

  • 'nested' The data is held in a series of nested arrays. For the most common case, a 2 dimensional table, this is an array of arrays.

  • 'flat' An object holding a flattened representation of an array of arrays. e.g. say data[3][5][1] = 12, then the corresponding entry in the flattened obejct would be data['3,5,1'] = 12

  • 'bucket' The easiest to read of the formats, this is identical to the data structure returned by keen: an array of objects which have a value for each axis and for the result e.g.

{
	'page.location.search': 'apples',
	timeframe: {
		start: 'an ISO string',
		end: 'an ISO string'
	},
	result: 12
}

data

The actual data

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