Skip to content

Commit 49f3429

Browse files
committed
Added draft tier based grouping of libraries in release report.
1 parent 53a1a94 commit 49f3429

File tree

7 files changed

+209
-75
lines changed

7 files changed

+209
-75
lines changed

libraries/forms.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525
get_mailinglist_counts,
2626
get_slack_channels,
2727
get_slack_stats,
28+
get_libraries_by_tier,
2829
)
2930
from versions.models import Version, ReportConfiguration
3031
from .models import (
3132
Commit,
3233
CommitAuthor,
3334
Library,
3435
CommitAuthorEmail,
36+
Tier,
3537
)
3638
from libraries.constants import SUB_LIBRARIES, RELEASE_REPORT_AUTHORS_PER_PAGE_THRESHOLD
3739
from mailing_list.models import EmailData
@@ -44,7 +46,7 @@
4446
count_commit_contributors_totals,
4547
get_new_contributors_count,
4648
)
47-
from .utils import conditional_batched
49+
from .utils import batched, conditional_batched
4850

4951
logger = get_logger(__name__)
5052

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

465467
library_data = get_library_data(library_order, prior_version.pk, version.pk)
466-
slack_stats = get_slack_stats(prior_version, version)
468+
libraries_without_tier = [
469+
lib["library"].name for lib in library_data if lib["library"].tier is None
470+
]
471+
if libraries_without_tier:
472+
raise ValueError(
473+
f"The following libraries have no tier assigned: {', '.join(libraries_without_tier)}"
474+
)
467475

476+
slack_stats = get_slack_stats(prior_version, version)
468477
library_index_library_data = get_libraries_for_index(
469478
library_data, version, prior_version
470479
)
471-
batched_library_data = conditional_batched(
472-
library_data,
473-
2,
474-
lambda x: x.get("top_contributors_release").count()
475-
<= RELEASE_REPORT_AUTHORS_PER_PAGE_THRESHOLD,
480+
flagship_libraries = [
481+
lib for lib in library_data if lib["library"].tier == Tier.FLAGSHIP
482+
]
483+
core_libraries = list(
484+
batched(
485+
[lib for lib in library_data if lib["library"].tier == Tier.CORE], 2
486+
)
487+
)
488+
deprecated_legacy_libraries = list(
489+
batched(
490+
[
491+
lib
492+
for lib in library_data
493+
if lib["library"].tier in (Tier.DEPRECATED, Tier.LEGACY)
494+
],
495+
28,
496+
)
476497
)
477498
git_graph_data = get_git_graph_data(prior_version, version)
478499
download = get_download_links(version)
@@ -505,8 +526,10 @@ def generate_context(
505526
"version_commit_count": version_commit_count,
506527
"top_contributors_release_overall": top_contributors,
507528
"library_data": library_data,
529+
"flagship_libraries": flagship_libraries,
530+
"batched_core_libraries": core_libraries,
531+
"batched_deprecated_legacy_libraries": deprecated_legacy_libraries,
508532
"new_libraries": new_libraries,
509-
"batched_library_data": batched_library_data,
510533
"top_libraries_for_version": top_libraries_for_version,
511534
"library_count": libraries.count(),
512535
"library_index_libraries": library_index_library_data,

reports/generation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ def get_libraries_by_quality(version):
290290
)
291291

292292

293+
def get_libraries_by_tier(version):
294+
# Returns libraries ordered by tier (flagship first), then by name.
295+
library_qs = get_library_queryset_by_version(version, annotate_commit_count=True)
296+
return library_qs.order_by("tier", "name")
297+
298+
293299
def get_library_version_counts(library_order, version):
294300
library_qs = get_library_queryset_by_version(version, annotate_commit_count=True)
295301
return sorted(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% load avatar_tags %}
2+
<div class="mx-auto mb-6">Top Contributors</div>
3+
<div class="m-auto grid grid-cols-1 gap-2">
4+
{% for author in library.top_contributors_release %}
5+
<div class="flex flex-row gap-y-2 w-40 items-center">
6+
{% avatar commitauthor=author %}
7+
<div class="w-full flex flex-col ml-2">
8+
<div class="text-[0.8rem] font-semibold overflow-ellipsis overflow-hidden whitespace-nowrap w-full">
9+
{{ author.display_name }}
10+
</div>
11+
<div class="text-[0.7rem]"><span class="font-bold">{{ author.commit_count }}</span> commit{{ author.commit_count|pluralize }}</div>
12+
</div>
13+
</div>
14+
{% endfor %}
15+
</div>

templates/admin/release_report_detail.html

Lines changed: 28 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -493,77 +493,40 @@ <h2 class="mx-auto">New Libraries</h2>
493493
{% endif %}
494494
{% 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 %}
495495
{% with bg_list=bg_list_str|split:"," %}
496-
{% for batch in batched_library_data %}
496+
{# Flagship Library handling #}
497+
{% for library in flagship_libraries %}
497498
{% with current_bg=bg_list|get_modulo_item:forloop.counter0 %}
498499
<div class="pdf-page flex flex-col {{ bg_color }}" style="background-image: url('{% static current_bg %}')">
499-
{% for item in batch %}
500-
<div class="grid grid-cols-3 gap-x-8 w-full p-4 h-1/2" id="library-{{ item.library.display_name }}">
501-
<div class="col-span-2 flex flex-col gap-y-4">
502-
<div class="flex flex-col gap-y-4">
503-
<h2 class="text-orange mb-1 mt-0">{{ item.library.display_name }}</h2>
504-
<div>{{ item.library.description }}</div>
505-
</div>
506-
<div class="flex gap-x-8 items-center">
507-
{% if item.library.graphic %}
508-
<div class="max-w-[10rem]">
509-
<img src="{{ item.library.graphic.url }}" alt="" />
510-
</div>
511-
{% endif %}
512-
<div class="flex flex-col gap-y-1">
513-
<div>
514-
There
515-
{{ item.version_count.commit_count|pluralize:"was,were" }}
516-
<span class="font-bold">{{ item.version_count.commit_count }}</span>
517-
commit{{ item.version_count.commit_count|pluralize }}
518-
in release {{ report_configuration.display_name }}
519-
</div>
520-
{% with insertions=item.library_version.insertions deletions=item.library_version.deletions %}
521-
<div>
522-
<span class="font-bold">{{ insertions|intcomma }}</span> line{{ insertions|pluralize }} added, <span class="font-bold">{{ deletions|intcomma }}</span> line{{ deletions|pluralize }} removed
523-
</div>
524-
{% endwith %}
525-
{% with count=item.new_contributors_count.count %}
526-
{% if count >= 1 %}
527-
<div>
528-
There {{ count|pluralize:"was,were" }} <span class="font-bold">{{ count }}</span> new contributor{{ count|pluralize }} for this release!
529-
</div>
530-
{% endif %}
531-
{% endwith %}
532-
<div>
533-
There {{ item.issues.opened|pluralize:"was,were" }} <span class="font-bold">{{ item.issues.opened }}</span> issue{{ item.issues.opened|pluralize }} opened
534-
and {{ item.issues.closed|pluralize:"was,were" }} <span class="font-bold">{{ item.issues.closed }}</span> issue{{ item.issues.closed|pluralize }} closed
535-
</div>
536-
{% if item.deps.added or item.deps.removed %}
537-
<div>
538-
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
539-
and
540-
<span class="font-bold">{{ item.deps.removed|length }}</span> dependenc{{ item.deps.removed|length|pluralize:"y,ies" }} removed
541-
</div>
542-
{% endif %}
543-
</div>
544-
</div>
545-
</div>
546-
<div class="px-4">
547-
<div class="mx-auto mb-6">Top Contributors</div>
548-
<div class="m-auto grid grid-cols-1 gap-2">
549-
{% for author in item.top_contributors_release %}
550-
<div class="flex flex-row gap-y-2 w-40 items-center">
551-
{% avatar commitauthor=author %}
552-
<div class="w-full flex flex-col ml-2">
553-
<div class="text-[0.8rem] font-semibold overflow-ellipsis overflow-hidden whitespace-nowrap w-full">
554-
{{ author.display_name }}
555-
</div>
556-
<div class="text-[0.7rem]"><span class="font-bold">{{ author.commit_count }}</span> commit{{ author.commit_count|pluralize }}</div>
557-
</div>
558-
</div>
559-
{% endfor %}
560-
</div>
561-
</div>
562-
</div>
500+
{% include "./release_report_library_flagship.html" %}
501+
</div>
502+
{% endwith %}
503+
{% endfor %}
504+
505+
{# Core Library handling #}
506+
{% for library_batch in batched_core_libraries %}
507+
{% with current_bg=bg_list|get_modulo_item:forloop.counter0 %}
508+
<div class="pdf-page {{ bg_color }}" style="background-image: url('{% static current_bg %}')">
509+
{% for library in library_batch %}
510+
<div class="flex flex-col h-1/2">
511+
{% include "./release_report_library_core.html" %}
512+
</div>
563513
{% endfor %}
564514
</div>
565515
{% endwith %}
566516
{% endfor %}
517+
{# Remaining Library handling #}
518+
{% for library_batch in batched_deprecated_legacy_libraries %}
519+
{% with current_bg=bg_list|get_modulo_item:forloop.counter0 %}
520+
<div class="pdf-page {{ bg_color }}" style="background-image: url('{% static current_bg %}')">
521+
<table>
522+
{% for library in library_batch %}
523+
{% include "./release_report_library_deprecated_legacy.html" %}
524+
{% endfor %}
525+
</table>
526+
</div>
527+
{% endwith %}
528+
{% endfor %}
529+
567530
{% endwith %}
568531
{% endwith %}
569532
</div>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{% load countries humanize text_helpers %}
2+
3+
<div class="grid grid-cols-3 gap-x-8 w-full p-4 h-1/2" id="library-{{ library.library.name }}">
4+
<div class="col-span-2 flex flex-col gap-y-4">
5+
<div class="flex flex-col gap-y-4">
6+
<h2 class="text-orange mb-1 mt-0">{{ library.library.display_name }}</h2>
7+
<div>{{ library.library.description }}</div>
8+
</div>
9+
<div class="flex gap-x-8 items-center">
10+
{% if library.library.graphic %}
11+
<div class="max-w-[10rem]">
12+
<img src="{{ library.library.graphic.url }}" alt="" />
13+
</div>
14+
{% endif %}
15+
<div class="flex flex-col gap-y-1">
16+
<div>
17+
There
18+
{{ library.version_count.commit_count|pluralize:"was,were" }}
19+
<span class="font-bold">{{ library.version_count.commit_count }}</span>
20+
commit{{ library.version_count.commit_count|pluralize }}
21+
in release {{ report_configuration.display_name }}
22+
</div>
23+
{% with insertions=library.library_version.insertions deletions=library.library_version.deletions %}
24+
<div>
25+
<span class="font-bold">{{ insertions|intcomma }}</span> line{{ insertions|pluralize }} added, <span class="font-bold">{{ deletions|intcomma }}</span> line{{ deletions|pluralize }} removed
26+
</div>
27+
{% endwith %}
28+
{% with count=library.new_contributors_count.count %}
29+
{% if count >= 1 %}
30+
<div>
31+
There {{ count|pluralize:"was,were" }} <span class="font-bold">{{ count }}</span> new contributor{{ count|pluralize }} for this release!
32+
</div>
33+
{% endif %}
34+
{% endwith %}
35+
<div>
36+
There {{ library.issues.opened|pluralize:"was,were" }} <span class="font-bold">{{ library.issues.opened }}</span> issue{{ library.issues.opened|pluralize }} opened
37+
and {{ library.issues.closed|pluralize:"was,were" }} <span class="font-bold">{{ library.issues.closed }}</span> issue{{ library.issues.closed|pluralize }} closed
38+
</div>
39+
{% if library.deps.added or library.deps.removed %}
40+
<div>
41+
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
42+
and
43+
<span class="font-bold">{{ library.deps.removed|length }}</span> dependenc{{ library.deps.removed|length|pluralize:"y,ies" }} removed
44+
</div>
45+
{% endif %}
46+
</div>
47+
</div>
48+
</div>
49+
<div class="px-4">
50+
{% include "./release_report_contributors.html" %}
51+
</div>
52+
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{% load countries humanize avatar_tags text_helpers %}
2+
<tr class="text-xs">
3+
<td class="px-2">{{ library.library.name }}</td>
4+
<td class="px-2">
5+
{% for author in library.library.authors.all %}{{ author.display_name }}{% if not forloop.last %}, {% endif %}{% endfor %}
6+
</td>
7+
<td class="px-2">
8+
<span class="font-bold">{{ library.version_count.commit_count }}</span> commit{{ library.version_count.commit_count|pluralize }}
9+
</td>
10+
{% with insertions=library.library_version.insertions deletions=library.library_version.deletions %}
11+
<td class="px-2">
12+
<span class="font-bold">{{ insertions|intcomma }}</span> line{{ insertions|pluralize }} added,
13+
<span class="font-bold">{{ deletions|intcomma }}</span> line{{ deletions|pluralize }} removed
14+
</td>
15+
{% endwith %}
16+
{# {% with count=library.new_contributors_count.count %}#}
17+
{# <td class="px-2">#}
18+
{# {% if count >= 1 %}#}
19+
{# <span class="font-bold">{{ count }}</span> new contributor{{ count|pluralize }}#}
20+
{# {% endif %}#}
21+
{# </td>#}
22+
{# {% endwith %}#}
23+
</tr>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{% load countries humanize avatar_tags text_helpers %}
2+
3+
<div class="grid grid-cols-3 gap-x-8 w-full p-4 h-1/2" id="library-{{ library.library.name }}">
4+
<div class="col-span-2 flex flex-col gap-y-4">
5+
<div class="flex flex-col gap-y-4">
6+
<h2 class="text-orange mb-1 mt-0">{{ library.library.display_name }}</h2>
7+
<div>{{ library.library.description }}</div>
8+
</div>
9+
<div class="flex gap-x-8 items-center">
10+
{% if library.library.graphic %}
11+
<div class="max-w-[10rem]">
12+
<img src="{{ library.library.graphic.url }}" alt="" />
13+
</div>
14+
{% endif %}
15+
<div class="flex flex-col gap-y-1">
16+
<div>
17+
There
18+
{{ library.version_count.commit_count|pluralize:"was,were" }}
19+
<span class="font-bold">{{ library.version_count.commit_count }}</span>
20+
commit{{ library.version_count.commit_count|pluralize }}
21+
in release {{ report_configuration.display_name }}
22+
</div>
23+
{% with insertions=library.library_version.insertions deletions=library.library_version.deletions %}
24+
<div>
25+
<span class="font-bold">{{ insertions|intcomma }}</span> line{{ insertions|pluralize }} added, <span class="font-bold">{{ deletions|intcomma }}</span> line{{ deletions|pluralize }} removed
26+
</div>
27+
{% endwith %}
28+
{% with count=library.new_contributors_count.count %}
29+
{% if count >= 1 %}
30+
<div>
31+
There {{ count|pluralize:"was,were" }} <span class="font-bold">{{ count }}</span> new contributor{{ count|pluralize }} for this release!
32+
</div>
33+
{% endif %}
34+
{% endwith %}
35+
<div>
36+
There {{ library.issues.opened|pluralize:"was,were" }} <span class="font-bold">{{ library.issues.opened }}</span> issue{{ library.issues.opened|pluralize }} opened
37+
and {{ library.issues.closed|pluralize:"was,were" }} <span class="font-bold">{{ library.issues.closed }}</span> issue{{ library.issues.closed|pluralize }} closed
38+
</div>
39+
{% if library.deps.added or library.deps.removed %}
40+
<div>
41+
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
42+
and
43+
<span class="font-bold">{{ library.deps.removed|length }}</span> dependenc{{ library.deps.removed|length|pluralize:"y,ies" }} removed
44+
</div>
45+
{% endif %}
46+
</div>
47+
</div>
48+
</div>
49+
<div class="px-4">
50+
{% include "./release_report_contributors.html" %}
51+
</div>
52+
</div>

0 commit comments

Comments
 (0)