community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rbo...@apache.org
Subject svn commit: r1774100 - /comdev/tools/birthday.pl
Date Tue, 13 Dec 2016 20:45:26 GMT
Author: rbowen
Date: Tue Dec 13 20:45:25 2016
New Revision: 1774100

URL: http://svn.apache.org/viewvc?rev=1774100&view=rev
Log:
Use committes.json rather than projects.json

Modified:
    comdev/tools/birthday.pl

Modified: comdev/tools/birthday.pl
URL: http://svn.apache.org/viewvc/comdev/tools/birthday.pl?rev=1774100&r1=1774099&r2=1774100&view=diff
==============================================================================
--- comdev/tools/birthday.pl (original)
+++ comdev/tools/birthday.pl Tue Dec 13 20:45:25 2016
@@ -2,9 +2,17 @@
 
 # Generates the csv file that I import into Hootsuite each month to do
 # the #ApacheBirthday tweets.
-# Note that as per https://s.apache.org/C3K7 this output isn't actually
-# correct, which hopefully I can fix before I need to use this script
-# the next time.
+#
+# Caveats:
+#
+# The "n years" bit probably doesn't work if you're running it
+# for a month in the following year. eg, if you run it for January while
+# it's still December.
+#
+# This script takes a long time to run because it verifies that projects
+# actually exist, by loading their website. This is so that we're not
+# reporting on Attic'ed projects, and subprojects, and so on.
+#
 
 use strict;
 use warnings;
@@ -13,22 +21,32 @@ use LWP::UserAgent;
 use HTTP::Request;
 use Data::Dumper;
 
-my $month = $ARGV[0];
+my $V = 0; # Set to 1 to make it noisy
+
+usage() unless $ARGV[0] =~ m/\d/;
+my $month = sprintf("%02d", $ARGV[0]);
 usage() unless $month;
 
 my $thisyear = (localtime(time))[5] + 1900;
 
-my $where = 'https://projects.apache.org/json/foundation/projects.json';
+my $where = 'https://projects.apache.org/json/foundation/committees.json';
 
 # Fetch the json
-my $ua = LWP::UserAgent->new(timeout=>30, agent=>"Twitter4Ponies/0.1 ");
+my $ua = LWP::UserAgent->new(timeout=>5, agent=>"Twitter4Ponies/0.1 ");
 my $res = $ua->request(HTTP::Request->new(GET => $where)); 
 my $projects = parse_json( $res->content );
 
-foreach my $proj ( keys %$projects ) {
-    my $d = $projects->{$proj}->{created};
+foreach my $p ( @$projects ) {
+
+    my $proj = $p->{id};
+    my $d = $p->{established};
     next unless $d;
-    next unless $d =~ m/-$month-/;
+    next unless $d =~ m/-$month$/;
+
+    # Skip projects that aren't actually there. (Attic? Subprojects?)
+    warn "Checking the validity of $proj" if $V;
+    my $v = $ua->request(HTTP::Request->new(GET => "http://$proj.apache.org/"));
+    next unless $v->is_success();
 
     my $y = ( $d =~ m/(\d\d\d\d)/ )[0];
     my $age = $thisyear - $y;
@@ -36,7 +54,7 @@ foreach my $proj ( keys %$projects ) {
     print '"01/' . "$month/$thisyear 09:00:00" . '",';
     print '"';
     print "Happy birthday to " .
-            $projects->{$proj}->{name} .
+            $p->{name} .
             " celebrating " . $age;
     print ( ($age > 1) ? ' years ' : ' year ' );
     print "this month. #ApacheBirthday";
@@ -50,3 +68,4 @@ sub usage {
     print "Usage: ./birthday.pl MONTH - eg, ./birthday.pl 07\n";
     exit();
 }
+



Mime
View raw message