diff --git a/libraries/forms.py b/libraries/forms.py index 8edd6c51f..fa3a75818 100644 --- a/libraries/forms.py +++ b/libraries/forms.py @@ -25,6 +25,7 @@ get_mailinglist_counts, get_slack_channels, get_slack_stats, + get_libraries_by_tier, ) from versions.models import Version, ReportConfiguration from .models import ( @@ -32,6 +33,7 @@ CommitAuthor, Library, CommitAuthorEmail, + Tier, ) from libraries.constants import SUB_LIBRARIES, RELEASE_REPORT_AUTHORS_PER_PAGE_THRESHOLD from mailing_list.models import EmailData @@ -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__) @@ -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' @@ -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) @@ -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, diff --git a/reports/generation.py b/reports/generation.py index ee36c596c..54e9d2398 100644 --- a/reports/generation.py +++ b/reports/generation.py @@ -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( diff --git a/templates/admin/release_report_contributors.html b/templates/admin/release_report_contributors.html new file mode 100644 index 000000000..26ef74193 --- /dev/null +++ b/templates/admin/release_report_contributors.html @@ -0,0 +1,15 @@ +{% load avatar_tags %} +
Top Contributors
+
+ {% for author in library.top_contributors_release %} +
+ {% avatar commitauthor=author %} +
+
+ {{ author.display_name }} +
+
{{ author.commit_count }} commit{{ author.commit_count|pluralize }}
+
+
+ {% endfor %} +
diff --git a/templates/admin/release_report_detail.html b/templates/admin/release_report_detail.html index 53714af27..2de2d39e3 100644 --- a/templates/admin/release_report_detail.html +++ b/templates/admin/release_report_detail.html @@ -493,77 +493,40 @@

New Libraries

{% 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 %}
- {% for item in batch %} -
-
-
-

{{ item.library.display_name }}

-
{{ item.library.description }}
-
-
- {% if item.library.graphic %} -
- -
- {% endif %} -
-
- There - {{ item.version_count.commit_count|pluralize:"was,were" }} - {{ item.version_count.commit_count }} - commit{{ item.version_count.commit_count|pluralize }} - in release {{ report_configuration.display_name }} -
- {% with insertions=item.library_version.insertions deletions=item.library_version.deletions %} -
- {{ insertions|intcomma }} line{{ insertions|pluralize }} added, {{ deletions|intcomma }} line{{ deletions|pluralize }} removed -
- {% endwith %} - {% with count=item.new_contributors_count.count %} - {% if count >= 1 %} -
- There {{ count|pluralize:"was,were" }} {{ count }} new contributor{{ count|pluralize }} for this release! -
- {% endif %} - {% endwith %} -
- There {{ item.issues.opened|pluralize:"was,were" }} {{ item.issues.opened }} issue{{ item.issues.opened|pluralize }} opened - and {{ item.issues.closed|pluralize:"was,were" }} {{ item.issues.closed }} issue{{ item.issues.closed|pluralize }} closed -
- {% if item.deps.added or item.deps.removed %} -
- There {{ item.deps.added|length|pluralize:"was,were" }} {{ item.deps.added|length }} dependenc{{ item.deps.added|length|pluralize:"y,ies" }} added - and - {{ item.deps.removed|length }} dependenc{{ item.deps.removed|length|pluralize:"y,ies" }} removed -
- {% endif %} -
-
-
-
-
Top Contributors
-
- {% for author in item.top_contributors_release %} -
- {% avatar commitauthor=author %} -
-
- {{ author.display_name }} -
-
{{ author.commit_count }} commit{{ author.commit_count|pluralize }}
-
-
- {% endfor %} -
-
-
+ {% include "./release_report_library_flagship.html" %} +
+ {% endwith %} + {% endfor %} + + {# Core Library handling #} + {% for library_batch in batched_core_libraries %} + {% with current_bg=bg_list|get_modulo_item:forloop.counter0 %} +
+ {% for library in library_batch %} +
+ {% include "./release_report_library_core.html" %} +
{% endfor %}
{% endwith %} {% endfor %} + {# Remaining Library handling #} + {% for library_batch in batched_deprecated_legacy_libraries %} + {% with current_bg=bg_list|get_modulo_item:forloop.counter0 %} +
+ + {% for library in library_batch %} + {% include "./release_report_library_deprecated_legacy.html" %} + {% endfor %} +
+
+ {% endwith %} + {% endfor %} + {% endwith %} {% endwith %} diff --git a/templates/admin/release_report_library_core.html b/templates/admin/release_report_library_core.html new file mode 100644 index 000000000..5a5137893 --- /dev/null +++ b/templates/admin/release_report_library_core.html @@ -0,0 +1,52 @@ +{% load countries humanize text_helpers %} + +
+
+
+

{{ library.library.display_name }}

+
{{ library.library.description }}
+
+
+ {% if library.library.graphic %} +
+ +
+ {% endif %} +
+
+ There + {{ library.version_count.commit_count|pluralize:"was,were" }} + {{ library.version_count.commit_count }} + commit{{ library.version_count.commit_count|pluralize }} + in release {{ report_configuration.display_name }} +
+ {% with insertions=library.library_version.insertions deletions=library.library_version.deletions %} +
+ {{ insertions|intcomma }} line{{ insertions|pluralize }} added, {{ deletions|intcomma }} line{{ deletions|pluralize }} removed +
+ {% endwith %} + {% with count=library.new_contributors_count.count %} + {% if count >= 1 %} +
+ There {{ count|pluralize:"was,were" }} {{ count }} new contributor{{ count|pluralize }} for this release! +
+ {% endif %} + {% endwith %} +
+ There {{ library.issues.opened|pluralize:"was,were" }} {{ library.issues.opened }} issue{{ library.issues.opened|pluralize }} opened + and {{ library.issues.closed|pluralize:"was,were" }} {{ library.issues.closed }} issue{{ library.issues.closed|pluralize }} closed +
+ {% if library.deps.added or library.deps.removed %} +
+ There {{ library.deps.added|length|pluralize:"was,were" }} {{ library.deps.added|length }} dependenc{{ library.deps.added|length|pluralize:"y,ies" }} added + and + {{ library.deps.removed|length }} dependenc{{ library.deps.removed|length|pluralize:"y,ies" }} removed +
+ {% endif %} +
+
+
+
+ {% include "./release_report_contributors.html" %} +
+
diff --git a/templates/admin/release_report_library_deprecated_legacy.html b/templates/admin/release_report_library_deprecated_legacy.html new file mode 100644 index 000000000..e6816c294 --- /dev/null +++ b/templates/admin/release_report_library_deprecated_legacy.html @@ -0,0 +1,23 @@ +{% load countries humanize avatar_tags text_helpers %} + + {{ library.library.name }} + + {% for author in library.library.authors.all %}{{ author.display_name }}{% if not forloop.last %}, {% endif %}{% endfor %} + + + {{ library.version_count.commit_count }} commit{{ library.version_count.commit_count|pluralize }} + + {% with insertions=library.library_version.insertions deletions=library.library_version.deletions %} + + {{ insertions|intcomma }} line{{ insertions|pluralize }} added, + {{ deletions|intcomma }} line{{ deletions|pluralize }} removed + + {% endwith %} +{# {% with count=library.new_contributors_count.count %}#} +{# #} +{# {% if count >= 1 %}#} +{# {{ count }} new contributor{{ count|pluralize }}#} +{# {% endif %}#} +{# #} +{# {% endwith %}#} + diff --git a/templates/admin/release_report_library_flagship.html b/templates/admin/release_report_library_flagship.html new file mode 100644 index 000000000..5a78c2998 --- /dev/null +++ b/templates/admin/release_report_library_flagship.html @@ -0,0 +1,52 @@ +{% load countries humanize avatar_tags text_helpers %} + +
+
+
+

{{ library.library.display_name }}

+
{{ library.library.description }}
+
+
+ {% if library.library.graphic %} +
+ +
+ {% endif %} +
+
+ There + {{ library.version_count.commit_count|pluralize:"was,were" }} + {{ library.version_count.commit_count }} + commit{{ library.version_count.commit_count|pluralize }} + in release {{ report_configuration.display_name }} +
+ {% with insertions=library.library_version.insertions deletions=library.library_version.deletions %} +
+ {{ insertions|intcomma }} line{{ insertions|pluralize }} added, {{ deletions|intcomma }} line{{ deletions|pluralize }} removed +
+ {% endwith %} + {% with count=library.new_contributors_count.count %} + {% if count >= 1 %} +
+ There {{ count|pluralize:"was,were" }} {{ count }} new contributor{{ count|pluralize }} for this release! +
+ {% endif %} + {% endwith %} +
+ There {{ library.issues.opened|pluralize:"was,were" }} {{ library.issues.opened }} issue{{ library.issues.opened|pluralize }} opened + and {{ library.issues.closed|pluralize:"was,were" }} {{ library.issues.closed }} issue{{ library.issues.closed|pluralize }} closed +
+ {% if library.deps.added or library.deps.removed %} +
+ There {{ library.deps.added|length|pluralize:"was,were" }} {{ library.deps.added|length }} dependenc{{ library.deps.added|length|pluralize:"y,ies" }} added + and + {{ library.deps.removed|length }} dependenc{{ library.deps.removed|length|pluralize:"y,ies" }} removed +
+ {% endif %} +
+
+
+
+ {% include "./release_report_contributors.html" %} +
+