git.shiar.nl
/
sheet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
52ca162
)
browser: normalise all usage percentages
author
Mischa POSLAWSKY
<perl@shiar.org>
Wed, 8 Dec 2010 22:21:23 +0000
(23:21 +0100)
committer
Mischa POSLAWSKY
<perl@shiar.org>
Wed, 15 Dec 2010 21:40:44 +0000
(22:40 +0100)
browser.plp
patch
|
blob
|
history
diff --git
a/browser.plp
b/browser.plp
index 831962492a300d14ea3982ac67e31028d0bb42ca..19011ab21d91ae8b601244de11f0f2ce58a32ed4 100644
(file)
--- a/
browser.plp
+++ b/
browser.plp
@@
-123,7
+123,13
@@
$canihas ||= {
}
} @browsers
}; # fallback hash based on release semantics
}
} @browsers
}; # fallback hash based on release semantics
-my $scorediv = (max(map { ref $_ eq 'HASH' && sum(values %$_) } values %$canihas) // 1) / 100;
+my $usagemax = (max(map { ref $_ eq 'HASH' && sum(values %$_) } values %$canihas) // 1) / 100;
+
+my $usagepct = 1; # score multiplier for 0..100 result
+# normalise usage percentage to only include shown browsers
+$usagepct = 100 / featurescore({ # yes for every possible version
+ map { $_ => { map {$_ => 'y'} @{$versions{$_}} } } keys %versions
+});
print '<table class="mapped">';
print '<col span="3">'; # should match first thead row
print '<table class="mapped">';
print '<col span="3">'; # should match first thead row
@@
-141,7
+147,7
@@
my $header = join('',
$_, @{ $caniuse->{agents}->{$_} }{'prefix', 'type'},
),
join(' ',
$_, @{ $caniuse->{agents}->{$_} }{'prefix', 'type'},
),
join(' ',
- sprintf('%.1f%%', sum(values %{ $canihas->{$_} })),
+ sprintf('%.1f%%', sum(values %{ $canihas->{$_} })
* $usagepct
),
$name,
),
do {
$name,
),
do {
@@
-159,7
+165,7
@@
print '<td>' x 3;
for my $browser (@browsers) {
printf('<td title="%s"%s>%s',
join(' ',
for my $browser (@browsers) {
printf('<td title="%s"%s>%s',
join(' ',
- sprintf('%.1f%%', $canihas->{$browser}->{$_}),
+ sprintf('%.1f%%', $canihas->{$browser}->{$_}
* $usagepct
),
"version $_",
),
(map {
"version $_",
),
(map {
@@
-174,7
+180,7
@@
say '<tfoot>', $header, '</tfoot>';
sub featurescore {
# relative amount of support for given feature
sub featurescore {
# relative amount of support for given feature
- state $statspts = { y=>1
0, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, 'p p'=>2, p=>
1 };
+ state $statspts = { y=>1
, 'y x'=>1, a=>.5, 'a x'=>.5, j=>.2, 'p j'=>.2, 'p p'=>.2, p=>.
1 };
my $rank = 0;
if (my $row = shift) {
if ($canihas) {
my $rank = 0;
if (my $row = shift) {
if ($canihas) {
@@
-258,13
+264,13
@@
sub saybrowsercols {
join(' ',
X => $CSTATS{ ref $data eq 'HASH' && $data->{$prev} || 'u' },
!$usage ? ('p0') : ('p',
join(' ',
X => $CSTATS{ ref $data eq 'HASH' && $data->{$prev} || 'u' },
!$usage ? ('p0') : ('p',
- sprintf('p%01d', $usage / 10),
- sprintf('p%02d', $usage),
+ sprintf('p%01d', $usage
* ($usagepct - .0001)
/ 10),
+ sprintf('p%02d', $usage
* ($usagepct - .0001)
),
),
),
- sprintf('pp%02d', $usage / $
scorediv
),
+ sprintf('pp%02d', $usage / $
usagemax
),
),
scalar @span,
),
scalar @span,
- sprintf('%.1f%% %s', $usage, join(', ',
+ sprintf('%.1f%% %s', $usage
* $usagepct
, join(', ',
map { ref $_ eq 'CODE' ? $_->($browser) : $_ }
map { $DSTATS{$_} // () }
map { split / /, $_ }
map { ref $_ eq 'CODE' ? $_->($browser) : $_ }
map { $DSTATS{$_} // () }
map { split / /, $_ }
@@
-281,10
+287,7
@@
sub saybrowsercols {
sub sayusagecol {
my ($id) = @_;
sub sayusagecol {
my ($id) = @_;
- state $maxscore = featurescore({ # yes for every possible version
- map { $_ => { map {$_ => 'y'} @{$versions{$_}} } } keys %versions
- });
- print '<td>', int featurescore($caniuse->{data}->{$id}->{stats}) / $maxscore * 100;
+ print '<td>', int featurescore($caniuse->{data}->{$id}->{stats}) * $usagepct;
}
say '<tbody>';
}
say '<tbody>';