Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 33 additions & 10 deletions libraries/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
get_mailinglist_counts,
get_slack_channels,
get_slack_stats,
get_libraries_by_tier,
)
from versions.models import Version, ReportConfiguration
from .models import (
Commit,
CommitAuthor,
Library,
CommitAuthorEmail,
Tier,
)
from libraries.constants import SUB_LIBRARIES, RELEASE_REPORT_AUTHORS_PER_PAGE_THRESHOLD
from mailing_list.models import EmailData
Expand All @@ -44,7 +46,7 @@
count_commit_contributors_totals,
get_new_contributors_count,
)
from .utils import conditional_batched
from .utils import batched, conditional_batched

logger = get_logger(__name__)

Expand Down Expand Up @@ -443,8 +445,8 @@ def generate_context(
# Compute the synchronous stats that don't require async tasks
commit_count, version_commit_count = get_commit_counts(version)
top_libraries_for_version = get_top_libraries_for_version(version)
top_libraries_by_name = get_libraries_by_name(version)
library_order = self._get_library_order(top_libraries_by_name)
libraries_by_tier = get_libraries_by_tier(version)
library_order = self._get_library_order(libraries_by_tier)
# TODO: we may in future need to find a way to show the removed libraries, for
# now it's not needed. In that case the distinction between running this on a
# ReportConfiguration with a real 'version' entry vs one that instead uses 'master'
Expand All @@ -463,16 +465,35 @@ def generate_context(
removed_library_count = 0

library_data = get_library_data(library_order, prior_version.pk, version.pk)
slack_stats = get_slack_stats(prior_version, version)
libraries_without_tier = [
lib["library"].name for lib in library_data if lib["library"].tier is None
]
if libraries_without_tier:
raise ValueError(
f"The following libraries have no tier assigned: {', '.join(libraries_without_tier)}"
)

slack_stats = get_slack_stats(prior_version, version)
library_index_library_data = get_libraries_for_index(
library_data, version, prior_version
)
batched_library_data = conditional_batched(
library_data,
2,
lambda x: x.get("top_contributors_release").count()
<= RELEASE_REPORT_AUTHORS_PER_PAGE_THRESHOLD,
flagship_libraries = [
lib for lib in library_data if lib["library"].tier == Tier.FLAGSHIP
]
core_libraries = list(
batched(
[lib for lib in library_data if lib["library"].tier == Tier.CORE], 2
)
)
deprecated_legacy_libraries = list(
batched(
[
lib
for lib in library_data
if lib["library"].tier in (Tier.DEPRECATED, Tier.LEGACY)
],
28,
)
)
git_graph_data = get_git_graph_data(prior_version, version)
download = get_download_links(version)
Expand Down Expand Up @@ -505,8 +526,10 @@ def generate_context(
"version_commit_count": version_commit_count,
"top_contributors_release_overall": top_contributors,
"library_data": library_data,
"flagship_libraries": flagship_libraries,
"batched_core_libraries": core_libraries,
"batched_deprecated_legacy_libraries": deprecated_legacy_libraries,
"new_libraries": new_libraries,
"batched_library_data": batched_library_data,
"top_libraries_for_version": top_libraries_for_version,
"library_count": libraries.count(),
"library_index_libraries": library_index_library_data,
Expand Down
6 changes: 6 additions & 0 deletions reports/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ def get_libraries_by_quality(version):
)


def get_libraries_by_tier(version):
# Returns libraries ordered by tier (flagship first), then by name.
library_qs = get_library_queryset_by_version(version, annotate_commit_count=True)
return library_qs.order_by("tier", "name")


def get_library_version_counts(library_order, version):
library_qs = get_library_queryset_by_version(version, annotate_commit_count=True)
return sorted(
Expand Down
15 changes: 15 additions & 0 deletions templates/admin/release_report_contributors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% load avatar_tags %}
<div class="mx-auto mb-6">Top Contributors</div>
<div class="m-auto grid grid-cols-1 gap-2">
{% for author in library.top_contributors_release %}
<div class="flex flex-row gap-y-2 w-40 items-center">
{% avatar commitauthor=author %}
<div class="w-full flex flex-col ml-2">
<div class="text-[0.8rem] font-semibold overflow-ellipsis overflow-hidden whitespace-nowrap w-full">
{{ author.display_name }}
</div>
<div class="text-[0.7rem]"><span class="font-bold">{{ author.commit_count }}</span> commit{{ author.commit_count|pluralize }}</div>
</div>
</div>
{% endfor %}
</div>
93 changes: 28 additions & 65 deletions templates/admin/release_report_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -493,77 +493,40 @@ <h2 class="mx-auto">New Libraries</h2>
{% endif %}
{% with "img/release_report/bg1.png,img/release_report/bg4-rev.png,img/release_report/bg3-rev.png,img/release_report/bg1-rev.png,img/release_report/bg2.png,img/release_report/bg6-rev.png,img/release_report/bg3.png,img/release_report/bg4.png,img/release_report/bg5.png,img/release_report/bg6.png,img/release_report/bg2-rev.png" as bg_list_str %}
{% with bg_list=bg_list_str|split:"," %}
{% for batch in batched_library_data %}
{# Flagship Library handling #}
{% for library in flagship_libraries %}
{% with current_bg=bg_list|get_modulo_item:forloop.counter0 %}
<div class="pdf-page flex flex-col {{ bg_color }}" style="background-image: url('{% static current_bg %}')">
{% for item in batch %}
<div class="grid grid-cols-3 gap-x-8 w-full p-4 h-1/2" id="library-{{ item.library.display_name }}">
<div class="col-span-2 flex flex-col gap-y-4">
<div class="flex flex-col gap-y-4">
<h2 class="text-orange mb-1 mt-0">{{ item.library.display_name }}</h2>
<div>{{ item.library.description }}</div>
</div>
<div class="flex gap-x-8 items-center">
{% if item.library.graphic %}
<div class="max-w-[10rem]">
<img src="{{ item.library.graphic.url }}" alt="" />
</div>
{% endif %}
<div class="flex flex-col gap-y-1">
<div>
There
{{ item.version_count.commit_count|pluralize:"was,were" }}
<span class="font-bold">{{ item.version_count.commit_count }}</span>
commit{{ item.version_count.commit_count|pluralize }}
in release {{ report_configuration.display_name }}
</div>
{% with insertions=item.library_version.insertions deletions=item.library_version.deletions %}
<div>
<span class="font-bold">{{ insertions|intcomma }}</span> line{{ insertions|pluralize }} added, <span class="font-bold">{{ deletions|intcomma }}</span> line{{ deletions|pluralize }} removed
</div>
{% endwith %}
{% with count=item.new_contributors_count.count %}
{% if count >= 1 %}
<div>
There {{ count|pluralize:"was,were" }} <span class="font-bold">{{ count }}</span> new contributor{{ count|pluralize }} for this release!
</div>
{% endif %}
{% endwith %}
<div>
There {{ item.issues.opened|pluralize:"was,were" }} <span class="font-bold">{{ item.issues.opened }}</span> issue{{ item.issues.opened|pluralize }} opened
and {{ item.issues.closed|pluralize:"was,were" }} <span class="font-bold">{{ item.issues.closed }}</span> issue{{ item.issues.closed|pluralize }} closed
</div>
{% if item.deps.added or item.deps.removed %}
<div>
There {{ item.deps.added|length|pluralize:"was,were" }} <span class="font-bold">{{ item.deps.added|length }}</span> dependenc{{ item.deps.added|length|pluralize:"y,ies" }} added
and
<span class="font-bold">{{ item.deps.removed|length }}</span> dependenc{{ item.deps.removed|length|pluralize:"y,ies" }} removed
</div>
{% endif %}
</div>
</div>
</div>
<div class="px-4">
<div class="mx-auto mb-6">Top Contributors</div>
<div class="m-auto grid grid-cols-1 gap-2">
{% for author in item.top_contributors_release %}
<div class="flex flex-row gap-y-2 w-40 items-center">
{% avatar commitauthor=author %}
<div class="w-full flex flex-col ml-2">
<div class="text-[0.8rem] font-semibold overflow-ellipsis overflow-hidden whitespace-nowrap w-full">
{{ author.display_name }}
</div>
<div class="text-[0.7rem]"><span class="font-bold">{{ author.commit_count }}</span> commit{{ author.commit_count|pluralize }}</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% include "./release_report_library_flagship.html" %}
</div>
{% endwith %}
{% endfor %}

{# Core Library handling #}
{% for library_batch in batched_core_libraries %}
{% with current_bg=bg_list|get_modulo_item:forloop.counter0 %}
<div class="pdf-page {{ bg_color }}" style="background-image: url('{% static current_bg %}')">
{% for library in library_batch %}
<div class="flex flex-col h-1/2">
{% include "./release_report_library_core.html" %}
</div>
{% endfor %}
</div>
{% endwith %}
{% endfor %}
{# Remaining Library handling #}
{% for library_batch in batched_deprecated_legacy_libraries %}
{% with current_bg=bg_list|get_modulo_item:forloop.counter0 %}
<div class="pdf-page {{ bg_color }}" style="background-image: url('{% static current_bg %}')">
<table>
{% for library in library_batch %}
{% include "./release_report_library_deprecated_legacy.html" %}
{% endfor %}
</table>
</div>
{% endwith %}
{% endfor %}

{% endwith %}
{% endwith %}
</div>
Expand Down
52 changes: 52 additions & 0 deletions templates/admin/release_report_library_core.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% load countries humanize text_helpers %}

<div class="grid grid-cols-3 gap-x-8 w-full p-4 h-1/2" id="library-{{ library.library.name }}">
<div class="col-span-2 flex flex-col gap-y-4">
<div class="flex flex-col gap-y-4">
<h2 class="text-orange mb-1 mt-0">{{ library.library.display_name }}</h2>
<div>{{ library.library.description }}</div>
</div>
<div class="flex gap-x-8 items-center">
{% if library.library.graphic %}
<div class="max-w-[10rem]">
<img src="{{ library.library.graphic.url }}" alt="" />
</div>
{% endif %}
<div class="flex flex-col gap-y-1">
<div>
There
{{ library.version_count.commit_count|pluralize:"was,were" }}
<span class="font-bold">{{ library.version_count.commit_count }}</span>
commit{{ library.version_count.commit_count|pluralize }}
in release {{ report_configuration.display_name }}
</div>
{% with insertions=library.library_version.insertions deletions=library.library_version.deletions %}
<div>
<span class="font-bold">{{ insertions|intcomma }}</span> line{{ insertions|pluralize }} added, <span class="font-bold">{{ deletions|intcomma }}</span> line{{ deletions|pluralize }} removed
</div>
{% endwith %}
{% with count=library.new_contributors_count.count %}
{% if count >= 1 %}
<div>
There {{ count|pluralize:"was,were" }} <span class="font-bold">{{ count }}</span> new contributor{{ count|pluralize }} for this release!
</div>
{% endif %}
{% endwith %}
<div>
There {{ library.issues.opened|pluralize:"was,were" }} <span class="font-bold">{{ library.issues.opened }}</span> issue{{ library.issues.opened|pluralize }} opened
and {{ library.issues.closed|pluralize:"was,were" }} <span class="font-bold">{{ library.issues.closed }}</span> issue{{ library.issues.closed|pluralize }} closed
</div>
{% if library.deps.added or library.deps.removed %}
<div>
There {{ library.deps.added|length|pluralize:"was,were" }} <span class="font-bold">{{ library.deps.added|length }}</span> dependenc{{ library.deps.added|length|pluralize:"y,ies" }} added
and
<span class="font-bold">{{ library.deps.removed|length }}</span> dependenc{{ library.deps.removed|length|pluralize:"y,ies" }} removed
</div>
{% endif %}
</div>
</div>
</div>
<div class="px-4">
{% include "./release_report_contributors.html" %}
</div>
</div>
23 changes: 23 additions & 0 deletions templates/admin/release_report_library_deprecated_legacy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% load countries humanize avatar_tags text_helpers %}
<tr class="text-xs">
<td class="px-2">{{ library.library.name }}</td>
<td class="px-2">
{% for author in library.library.authors.all %}{{ author.display_name }}{% if not forloop.last %}, {% endif %}{% endfor %}
</td>
<td class="px-2">
<span class="font-bold">{{ library.version_count.commit_count }}</span> commit{{ library.version_count.commit_count|pluralize }}
</td>
{% with insertions=library.library_version.insertions deletions=library.library_version.deletions %}
<td class="px-2">
<span class="font-bold">{{ insertions|intcomma }}</span> line{{ insertions|pluralize }} added,
<span class="font-bold">{{ deletions|intcomma }}</span> line{{ deletions|pluralize }} removed
</td>
{% endwith %}
{# {% with count=library.new_contributors_count.count %}#}
{# <td class="px-2">#}
{# {% if count >= 1 %}#}
{# <span class="font-bold">{{ count }}</span> new contributor{{ count|pluralize }}#}
{# {% endif %}#}
{# </td>#}
{# {% endwith %}#}
</tr>
52 changes: 52 additions & 0 deletions templates/admin/release_report_library_flagship.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% load countries humanize avatar_tags text_helpers %}

<div class="grid grid-cols-3 gap-x-8 w-full p-4 h-1/2" id="library-{{ library.library.name }}">
<div class="col-span-2 flex flex-col gap-y-4">
<div class="flex flex-col gap-y-4">
<h2 class="text-orange mb-1 mt-0">{{ library.library.display_name }}</h2>
<div>{{ library.library.description }}</div>
</div>
<div class="flex gap-x-8 items-center">
{% if library.library.graphic %}
<div class="max-w-[10rem]">
<img src="{{ library.library.graphic.url }}" alt="" />
</div>
{% endif %}
<div class="flex flex-col gap-y-1">
<div>
There
{{ library.version_count.commit_count|pluralize:"was,were" }}
<span class="font-bold">{{ library.version_count.commit_count }}</span>
commit{{ library.version_count.commit_count|pluralize }}
in release {{ report_configuration.display_name }}
</div>
{% with insertions=library.library_version.insertions deletions=library.library_version.deletions %}
<div>
<span class="font-bold">{{ insertions|intcomma }}</span> line{{ insertions|pluralize }} added, <span class="font-bold">{{ deletions|intcomma }}</span> line{{ deletions|pluralize }} removed
</div>
{% endwith %}
{% with count=library.new_contributors_count.count %}
{% if count >= 1 %}
<div>
There {{ count|pluralize:"was,were" }} <span class="font-bold">{{ count }}</span> new contributor{{ count|pluralize }} for this release!
</div>
{% endif %}
{% endwith %}
<div>
There {{ library.issues.opened|pluralize:"was,were" }} <span class="font-bold">{{ library.issues.opened }}</span> issue{{ library.issues.opened|pluralize }} opened
and {{ library.issues.closed|pluralize:"was,were" }} <span class="font-bold">{{ library.issues.closed }}</span> issue{{ library.issues.closed|pluralize }} closed
</div>
{% if library.deps.added or library.deps.removed %}
<div>
There {{ library.deps.added|length|pluralize:"was,were" }} <span class="font-bold">{{ library.deps.added|length }}</span> dependenc{{ library.deps.added|length|pluralize:"y,ies" }} added
and
<span class="font-bold">{{ library.deps.removed|length }}</span> dependenc{{ library.deps.removed|length|pluralize:"y,ies" }} removed
</div>
{% endif %}
</div>
</div>
</div>
<div class="px-4">
{% include "./release_report_contributors.html" %}
</div>
</div>