Feature list sorting

This commit is contained in:
Jakob Borg 2015-09-30 08:29:41 +02:00
parent c8c4b090ef
commit 1ded36fcff
2 changed files with 24 additions and 9 deletions

View File

@ -693,11 +693,14 @@ func getReport(db *sql.DB) map[string]interface{} {
featureNames = append(featureNames, key)
}
sort.Strings(featureNames)
for _, key := range featureNames {
featureList = append(featureList, feature{
Key: key,
Pct: (100 * features[key]) / v2Reports,
})
if v2Reports > 0 {
for _, key := range featureNames {
featureList = append(featureList, feature{
Key: key,
Pct: (100 * features[key]) / v2Reports,
})
}
sort.Sort(sort.Reverse(sortableFeatureList(featureList)))
}
r := make(map[string]interface{})
@ -881,3 +884,15 @@ func getMovement(db *sql.DB) ([][]interface{}, error) {
return res, nil
}
type sortableFeatureList []feature
func (l sortableFeatureList) Len() int {
return len(l)
}
func (l sortableFeatureList) Swap(a, b int) {
l[a], l[b] = l[b], l[a]
}
func (l sortableFeatureList) Less(a, b int) bool {
return l[a].Pct < l[b].Pct
}

View File

@ -100,13 +100,13 @@ found in the LICENSE file.
<div class="col-md-12">
<h1>Syncthing Usage Data</h1>
<h4>Active Users per Day and Version</h4>
<h4 id="active-users">Active Users per Day and Version</h4>
<p>
This is the total number of unique users with reporting enabled, per day. Area color represents the major version.
</p>
<div class="img-thumbnail" id="versionChart" style="width: 1130px; height: 400px; padding: 10px;"></div>
<h4>Users Joining and Leaving per Day</h4>
<h4 id="joining-leaving">Users Joining and Leaving per Day</h4>
<p>
This is the total number of unique users joining and leaving per day. A user is counted as "joined" on first the day their unique ID is seen, and as "left" on the last day the unique ID was seen before a two weeks or longer absence. "Bounced" refers to users who joined and left on the same day.
</p>
@ -116,7 +116,7 @@ found in the LICENSE file.
Spikes in December 2014 were due to the unique ID format changing and have been partly removed to avoid skewing the graph scale.
</p>
<h4>Usage Metrics</h4>
<h4 id="metrics">Usage Metrics</h4>
<p>
This is the aggregated usage report data for the last 24 hours. Data based on <b>{{.nodes}}</b> devices that have reported in.
</p>
@ -246,7 +246,7 @@ found in the LICENSE file.
<div class="row">
<div class="col-md-12">
<h4>Feature Usage</h4>
<h4 id="features">Feature Usage</h4>
<p>
The following lists feature usage, as a percentage of the v0.12+ population (<b>{{.v2nodes}}</b> devices).
</p>