Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Introduce grouping of reported segments

  • Loading branch information...
commit 13b66a4bf753ca5ef8f6241aaafab15a99a2d7e3 1 parent 29f1415
@andreyvit andreyvit authored
Showing with 59 additions and 13 deletions.
  1. +42 −1 bin/report.coffee
  2. +13 −11 views/index.jade
  3. +4 −1 views/layout.jade
View
43 bin/report.coffee
@@ -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()
View
24 views/index.jade
@@ -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
View
5 views/layout.jade
@@ -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
@@ -18,7 +21,7 @@ html
span.divider /
!= content
-
+
script
$('table.with-headers').each(function() {
$(this).tablesorter({ sortList: [[0,0]] });
Please sign in to comment.
Something went wrong with that request. Please try again.