[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/01: c/r-html-reports: Add instance limit for tags template



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 19cee7dbe7c52e408810429e2da3e702951760e8
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Feb 1 21:46:28 2018 +0000

    c/r-html-reports: Add instance limit for tags template
    
    This reduces the size of the generated website by about 20% (220MB on
    lindsay.d.o).  In some cases, it will probably also make a huge
    difference in page load speed as we no longer have 10+ MB html pages
    for tags.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 commands/reporting-html-reports.pm | 25 ++++++++++++++++++++++++-
 debian/changelog                   |  9 +++++++++
 reporting/templates/tag.tmpl       | 20 +++++++++++++++++++-
 3 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/commands/reporting-html-reports.pm b/commands/reporting-html-reports.pm
index f4be328..749f153 100644
--- a/commands/reporting-html-reports.pm
+++ b/commands/reporting-html-reports.pm
@@ -404,17 +404,40 @@ sub process_data {
         my $description = $info->description('html', '    ');
         my ($count, $overrides) = (0, 0);
         my $tmpl = 'tag-not-seen';
+        my $shown_count = 0;
+        my $tag_list = $by_tag{$tag};
+        my $tag_limit_total = 1024;
+        my $tag_limit_per_package = 3;
+
         if (exists $by_tag{$tag}) {
             $tmpl = 'tag';
             $count = $tag_statistics{$tag}{'count'};
             $overrides = $tag_statistics{$tag}{'overrides'};
+            $shown_count = $count + $overrides;
+        }
+        if ($shown_count > $tag_limit_total) {
+            my (@replacement_list, %seen);
+            for my $orig_info (
+                sort { $a->{pkg_info}{package} cmp $b->{pkg_info}{package} }
+                @{$tag_list}) {
+                my $pkg_info = $orig_info->{pkg_info};
+                my $key
+                  = "$pkg_info->{package} $pkg_info->{type} $pkg_info->{version}";
+                next if ++$seen{$key} > $tag_limit_per_package;
+                push(@replacement_list, $orig_info);
+                last if @replacement_list >= $tag_limit_total;
+            }
+            $tag_list = \@replacement_list;
+            $shown_count = scalar(@replacement_list);
         }
 
         my %maint_data = (
             description => $description,
             tag         => $tag,
             code        => $info->code,
-            tags        => $by_tag{$tag},
+            tags        => $tag_list,
+            shown_count => $shown_count,
+            tag_limit_per_package => $tag_limit_per_package,
             graphs      => $GRAPHS,
             graphs_days => $GRAPHS_RANGE_DAYS,
             statistics  => {
diff --git a/debian/changelog b/debian/changelog
index 5ee535d..61ca98f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -54,6 +54,11 @@ lintian (2.5.73) UNRELEASED; urgency=medium
     + [CL] Ask maintainers to add a comment header to debian/copyright if
       their package is in contrib or non-free.  (Closes: #773562)
 
+  * commands/reporting-html-reports.pm:
+    + [NT] Add a limit to how many instances of a tag is deplayed on a tag
+      page as 151 000 instances of unstripped-static-library is hardly
+      human readable.
+
   * data/common/dh_addons:
     + [CL] Move/create from data/debhelper/dh_addons as we plan to use
       it elsewhere.
@@ -71,6 +76,10 @@ lintian (2.5.73) UNRELEASED; urgency=medium
     + [CL] Add support for passing .buildinfo files to Lintian.
       (Closes: #853274)
 
+  * reporting/templates/tag.tmpl:
+    + [NT] Update template to mention tag limit when not all instances
+      are shown.
+
  -- Chris Lamb <lamby@debian.org>  Fri, 26 Jan 2018 16:33:51 +1100
 
 lintian (2.5.72) unstable; urgency=medium
diff --git a/reporting/templates/tag.tmpl b/reporting/templates/tag.tmpl
index 9725d02..4fb3dd9 100644
--- a/reporting/templates/tag.tmpl
+++ b/reporting/templates/tag.tmpl
@@ -3,10 +3,28 @@
   head("Lintian Tag: ${q_tag}") }
   <h1><span class="type-{$code}">{$code}</span> {${q_tag}}</h1>
 
+{ if ($statistics{total} <= $shown_count) {
+  $OUT .= qq(
   <p>
-    All reports of {$tag} for the archive. The extended description of this
+    All reports of ${tag} for the archive. The extended description of this
     tag is:
   </p>
+);
+  } else {
+  $OUT .= qq(
+    <p>
+      A subset of the reports of ${tag} for the archive.  Unfortunately the full
+      list is too long, so only ${shown_count} instances are listed on this page.
+      At most ${tag_limit_per_package} tags are shown per package.
+      <a href="{resource_path('lintian.log.gz')}">If you need the full list of tags,
+       please download the lintian.log.gz file and extract the data you need.</a>
+    </p>
+    <p>
+      The extended description of this tag is:
+    </p>
+  );
+  }
+}
 
   <blockquote class="type-{$code}">
 {$description}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: