chiark / gitweb /
news - more stopwords
[rrd-graphs.git] / cgi
diff --git a/cgi b/cgi
index b9acb9422c5708284063a915cf35f61363654c5b..3be09344ff61a0356dd95db86c862481f940d42f 100755 (executable)
--- a/cgi
+++ b/cgi
@@ -45,11 +45,16 @@ our $SELF= '/home/ijackson/things/rrd-graphs';
 
 our @timeranges= (3600, map { $_*86400 } qw(1 7 28), 13*7+1, 366);
 
-sub graph_of_group ($$$$$) {
-    my ($section, $group, $elem, $basis, $args) = @_;
+sub graph_of_group ($$$$$;$) {
+    my ($section, $group, $elem, $basis, $args, $title) = @_;
     $basis->{Args}= $args;
     $basis->{Slower}= 0 unless exists $basis->{Slower};
     $basis->{TimeRanges} ||= \@timeranges;
+    if (!defined $title) {
+       $title = $group;
+       if (length $elem) { $title.= " $elem"; }
+    }
+    $basis->{Title} = $title;
     $graphs{$section,$group,$elem}= $basis;
     if (!exists $group_elems{$section,$group}) {
        # new group then
@@ -201,13 +206,17 @@ our @news_graphs;
 
 foreach my $site (keys %news_sources) {
     my $sk= $site;
+    $sk =~ s/^[.0-9]+$/~$&/;
     for (;;) {
         last unless $sk =~
           s/^[^.]*(?:chiark|greenend|news|nntp|peer|feed|in|out)[^.]*\.//;
s/^[^. ]*\b(?:chiark|greenend|news|newsfeed|nntp|peer|feeds?|feeder|in|out)\b[^.]*\.//;
         $sk .= " $&";
     }
+print STDERR "$site => $sk\n";
     foreach my $inout (keys %{ $news_sources{$site} }) {
-        push @news_graphs, [ "$sk $inout", $site, $inout ];
+       my $skio = $sk;
+       $skio =~ s/ / [$inout]/;
+        push @news_graphs, [ $skio, $site, $inout ];
     }
 }
 
@@ -233,7 +242,10 @@ foreach my $siteinfo (sort { $a->[0] cmp $b->[0] } @news_graphs) {
             push @defs, "CDEF:kb_$`=$val,1024,/";
         }
     }
-    graph_of_group("News", $site, $inout,
+    my $group = $sortkey;
+    $group =~ s/ .*//;
+    $group = $site unless length $group;
+    graph_of_group("News", $group, "$site $inout",
          {
                Units => '[art/s]',
                TimeRanges => [ map { $_*86400 } qw(1 7 31), 366, 366*3 ]
@@ -255,7 +267,8 @@ foreach my $siteinfo (sort { $a->[0] cmp $b->[0] } @news_graphs) {
           "CDEF:kb_accepted_smooth=kb_accepted,<interval/60>,TREND",
           "LINE:kb_duplicate#ff0:kb dupe",
           "LINE:kb_accepted_smooth#008:~kb",
-          ]);
+          ],
+       "$site $inout");
 }
 
 our %disk_rdev2rrd;
@@ -458,9 +471,7 @@ if (defined $elem) {
     s,\<interval/(\d+)\>, $end/$1 ,ge foreach @args;
     unshift @args, qw(--end now --start), "end-${end}s";
     
-    my $title= $group;
-    if (length $elem) { $title.= " $elem"; }
-
+    my $title = $g->{Title};
     $title .= " $g->{Units}" if $g->{Units};
     unshift @args, '-t', $title, '-w',$width, '-h',$height;
     unshift @args, qw(-a PNG --full-size-mode);