Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various PHP Trends improvements #738

Merged
merged 14 commits into from Apr 16, 2019

add adoption rate to last package, skip single-versioned packages, no…

… fun
  • Loading branch information...
TomasVotruba committed Apr 16, 2019
commit a3a6c099bb682b792d16b6d14ac8e5b7b5343d07
@@ -1,12 +1,29 @@
---
layout: "_layouts/default.twig"
title: "Package Monthly Downloads by Version"
id: trends
---

{% macro number(value) %}
{{ value|number_format(0, ',', ' ') }}
{% endmacro %}

{% macro adoption(value) %}
{% if value > 75 %}
<strong>
<span class="text-success">{{ value|number_format }} % adoption</span>
</strong>
{% elseif value > 50 %}
<span class="text-success">{{ value|number_format }} % adoption</span>
{% elseif value > 25 %}
<span class="text-danger">{{ value|number_format }} % adoption</span>
{% else %}
<strong>
<span class="text-danger">{{ value|number_format }} % adoption</span>
</strong>
{% endif %}
{% endmacro %}

{# local macros must be imported, then use like "{{ macros.<X>() }}" #}
{% import _self as macros %}

@@ -15,16 +32,16 @@ title: "Package Monthly Downloads by Version"

<p class="text-muted mb-4 small">Updated at {{ vendor_packages_by_version.updated_at|date('j. n. H:i') }}</p>

<p>Jump to framework</p>
<div class="text-center">
<h3 class="mb-4">Jump to framework</h3>

<div class="mb-4">
{% for framework in vendor_packages_by_version.vendors %}
<a href="#{{ framework.name|webalize }}" class="btn btn-warning mr-2">{{ framework.name }} ↓</a>
{% endfor %}
<div class="mb-4">
{% for framework in vendor_packages_by_version.vendors %}
<a href="#{{ framework.name|webalize }}" class="btn btn-warning mr-2">{{ framework.name }} ↓</a>
{% endfor %}
</div>
</div>

<p><strong>Adoption rate</strong> = how many people use the latest version of the package</p>

<br>

{% for framework in vendor_packages_by_version.vendors %}
@@ -41,50 +58,58 @@ title: "Package Monthly Downloads by Version"
</div>

{% for package_data in framework.packages_data %}
<table class="table table-bordered mt-4 mt-4">
<thead class="thead-inverse">
<tr>
<th>Version</th>
<th>Monthly Downloads</th>
</tr>
</thead>
<tr>
<th colspan="2" class="text-center bg-primary text-white">
{{ package_data.package_name }}
{% if package_data.adoption_rate < 100 %}
<br>
<p>{{ package_data.adoption_rate }} % on the last version</p>
{% endif %}
</th>
</tr>

{# is major different from minor? #}
{% if package_data.downloads_minor|length > package_data.downloads_major|length and package_data.downloads_major|length > 1 %}
<tr>
<th colspan="2" class="bg-primary text-white">Grouped by major version</th>
</tr>

{% for version, number in package_data.downloads_major %}
{% if package_data.downloads_minor|length > 1 %}
<table class="table table-bordered mt-4 mt-4">
<thead class="thead-inverse">
<tr>
<th colspan="2" class="text-center">
{{ package_data.package_name }}
</th>
</tr>
</thead>

{# is major different from minor? #}
{% if package_data.downloads_minor|length > package_data.downloads_major|length and package_data.downloads_major|length > 1 %}
<thead class="thead-inverse">
<tr>
<th colspan="2" class="text-center">Major</th>
</tr>
</thead>

{% for version, number in package_data.downloads_major %}
<tr>
<td class="w-50">{{ version }}</td>
<td class="w-50 text-right">
{{ macros.number(number) }}
</td>
</tr>
{% endfor %}

<thead class="thead-inverse">
<tr>
<th colspan="2" class="text-center">Minor</th>
</tr>
</thead>
{% endif %}

{% for version, number in package_data.downloads_minor %}
<tr>
<td class="w-50">{{ version }}</td>
<td class="w-50 text-right">{{ macros.number(number) }}</td>
<td class="w-50">
{{ version }}
</td>
<td class="w-50 text-right">
{% if loop.first and package_data.adoption_rate < 100 %}
<div class="float-left">
{{ macros.adoption(package_data.adoption_rate) }}
</div>
{% endif %}

{{ macros.number(number) }}
</td>
</tr>
{% endfor %}

<tr>
<th colspan="2" class="bg-primary text-white">
Grouped by minor version
</th>
</tr>
{% endif %}

{% for version, number in package_data.downloads_minor %}
<tr>
<td class="w-50">{{ version }}</td>
<td class="w-50 text-right">{{ macros.number(number) }}</td>
</tr>
{% endfor %}
</table>
</table>
{% endif %}
{% endfor %}
{% endfor %}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.