Skip to content

Commit

Permalink
Introduce grouping of reported segments
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyvit committed Dec 17, 2012
1 parent 29f1415 commit 13b66a4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 13 deletions.
43 changes: 42 additions & 1 deletion bin/report.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,59 @@ loadData = (groupName, func) ->
func(periodsToData, group.levels)


groupSegments = (sourceSegments, sourceGroups) ->
ungroupedSegments = Object.clone(sourceSegments)

groups = (Object.clone(group) for group in sourceGroups)
otherGroup = groups.pop()

for group in groups
group.regexp = new RegExp(("^" + RegExp.escape(key) for key in group.keys).join("|"))

groupRows = []

for keyPrefix in group.keys
otherRows = []
for row in ungroupedSegments.rows
if row.key.startsWith(keyPrefix)
groupRows.push(row)
else
otherRows.push(row)
ungroupedSegments.rows = otherRows

group.segments = { cols: ungroupedSegments.cols, rows: groupRows }

if ungroupedSegments.rows.length > 0
otherGroup.segments = ungroupedSegments
groups.push(otherGroup)

return groups


views = loadViews(Path.join(__dirname, '../views'))


segments = loadData('month-segments', temporalTransform.fill(10))

groups = groupSegments segments, [
{ title: "", keys: ["g:all"] }
{ title: "By engagement", keys: ["g:engagement:"] }
{ title: "By engagement history", keys: ["g:status:"] }
{ title: "By age", keys: ["g:knownfor:"] }
{ title: "By OS", keys: ["g:v:platform:", "g:v:os:"] }
{ title: "By OS (active users only)", keys: ["g:active:v:platform:", "g:active:v:os:"] }
{ title: "By version", keys: ["g:v:version:"] }
{ title: "By version (active users only)", keys: ["g:active:v:version:"] }
{ title: "Other segments"}
]


html = views.layout {
title: "LiveReload Statistics"
breadcrumbs: [
{ title: "LiveReload Statistics", active: yes }
]
content: views.index({ segments })
content: views.index({ groups })
}

DataFileGroups.html.mkdir()
Expand Down
24 changes: 13 additions & 11 deletions views/index.jade
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

h2 Segments
for group in groups
if group.title
h2= group.title

table.segments
tr
th Segment
for col in segments.cols
th= col.title

for row in segments.rows
table.segments
tr
td= row.key
for col in row.cols
td= col.value.count
th.segment  
for col in group.segments.cols
th= col.title

for row in group.segments.rows
tr
td.segment= row.key
for col in row.cols
td= col.value.count
5 changes: 4 additions & 1 deletion views/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ html
script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js")
script(src="http://files.tarantsov.com/jquery.tablesorter.min.js")
link(rel="stylesheet", href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css")
style
.segment { width: 150px }

body
.container
ul.breadcrumb
Expand All @@ -18,7 +21,7 @@ html
span.divider /

!= content

script
$('table.with-headers').each(function() {
$(this).tablesorter({ sortList: [[0,0]] });
Expand Down

0 comments on commit 13b66a4

Please sign in to comment.