-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailing-list-stats.pl
More file actions
executable file
·284 lines (258 loc) · 6.93 KB
/
mailing-list-stats.pl
File metadata and controls
executable file
·284 lines (258 loc) · 6.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/usr/bin/perl -w
use strict;
use warnings;
use LWP::Simple;
use Data::Dumper;
my $verbose = 1; #$ENV{VERBOSE} || 1;
my $emulate;
my $six_month_summary = 1;
my $local_dir = '/Users/gwg/Desktop/GMOD/gmod-scripts/';
my $temp_dir = '/Users/gwg/Desktop/GMOD/gmod-scripts/temp/';
my $data;
my $months = {
'January' => '01',
'February' => '02',
'March' => '03',
'April' => '04',
'May' => '05',
'June' => '06',
'July' => '07',
'August' => '08',
'September' => '09',
'October' => 10,
'November' => 11,
'December' => 12,
};
my $sf_lists = [
"ergatis-announce",
"ergatis-devel",
"ergatis-users",
"gmod-ajax",
"gmod-announce",
# "gmod-apollo-cmts",
"gmod-architecture",
# "gmod-biographics-commits",
"gmod-chado-seq-ad",
"gmod-citrina",
"gmod-cmae",
# "gmod-cmap-commits",
"gmod-cmap",
"gmod-cogephy",
# "gmod-das2-cmts",
"gmod-devel",
# "gmod-gbrowse-cmts",
"gmod-gbrowse",
"gmod-gene-page",
"gmod-ontol-sw-dev",
"gmod-phendiver",
"gmod-pubsearch-dv",
"gmod-resources",
# "gmod-schema-cmts",
"gmod-schema",
"gmod-tripal-devel",
"gmod-tripal",
"gmod-ware-users",
# "gmod-web-cmts",
"gmod-webgbrowse",
"isga-users",
"sybil-info",
# "turnkey-cmts",
"turnkey-devel",
"turnkey-users",
];
## SF lists: http://sourceforge.net/mailarchive/forum.php?forum_name=$list_name
## URLs: <a href="forum.php?forum_name=$list_name&max_rows=25&style=ultimate&viewmonth=YYYYMM">(23)</a>
unless ($emulate)
{
foreach my $l (@$sf_lists)
{ my $url = 'http://sourceforge.net/mailarchive/forum.php?forum_name=' . $l;
print STDERR "Getting $url...\n" if $verbose;
my $page = get( $url );
if (! defined ($page) )
{ warn "SF page for $l not found";
next;
}
while ($page =~ /<a href="forum.php\?forum_name=$l&max_rows=25&style=ultimate&viewmonth=(\d{4})(\d{2})">\((\d+)\)<\/a>/g)
{ ## we have /viewmonth=YYYYMM">(\d+)
# print STDERR "$1 -- $2 -- $3\n";
$data->{by_date}{$1}{$2}{$l} = $3;
$data->{by_list}{$l}{$1}{$2} = $3;
}
if (! $data->{by_list}{$l})
{ warn "No data found for $l";
## save the file to a temp dir to examine manually
my $fh = $l . "-index.html";
if ( open(FH, "> $temp_dir$fh") )
{ print FH $page;
close FH;
}
else
{ die "Could not open $fh: $!\n";
}
}
}
print STDERR "Finished processing SF mailing lists\n" if $verbose;
}
my $url_h = {
## no response from biomart - due to https?
'biomart_users' => 'https://lists.biomart.org/pipermail/users/',
'biomart_announce' => 'https://lists.biomart.org/pipermail/announce/',
## 'apollo' => 'https://lists.lbl.gov/sympa/info/apollo',
'galaxy_announce' => 'http://lists.bx.psu.edu/pipermail/galaxy-announce/',
'galaxy_dev' => 'http://lists.bx.psu.edu/pipermail/galaxy-dev/',
'galaxy_user' => 'http://lists.bx.psu.edu/pipermail/galaxy-user/',
'maker-devel' => 'http://box290.bluehost.com/pipermail/maker-devel_yandell-lab.org/',
'intermine' => 'http://mail.intermine.org/pipermail/dev/',
};
foreach my $l (keys %$url_h)
{ my $url = $url_h->{$l};
print STDERR "url: $url\n" if $verbose;
my $index = get( $url );
if (! defined ($index) )
{ warn "Query returned no data";
next;
}
## OK, let's get all the URLs ending in 'date.html'
my @date_urls = ($index =~ /<a href="(\d{4}-[A-Z][a-z]{2,10}\/date.html)">\[ Date \]<\/a>/gi);
if (! @date_urls || scalar @date_urls == 0)
{ warn "No dates found for $l";
## temporarily save the data to a file
my $fh = $l . "-index.html";
if ( open(FH, "> $temp_dir$fh") )
{ print FH $index;
close FH;
}
else
{ die "Could not open $fh: $!\n";
}
next;
}
foreach my $d (@date_urls)
{ ## let's get those URLs!
print STDERR "Getting $url$d\n" if $verbose;
my $page = get($url . $d);
if (! defined $page)
{ warn "No data found for $d";
}
else
{ ## find the count
my $err;
if ($page =~ /<b>Messages:<\/b> (\d+)<p>/)
{ my $n = $1;
## convert the date into YYYY DD format
## current format: YYYY-name of month
if ($d =~ /^(\d{4})-([A-Z][a-z]{2,10})\/date.html/)
{ if (! $months->{$2})
{ warn "$l: month $2 in $d unknown";
$err++;
}
else
{ $data->{by_date}{$1}{$months->{$2}}{$l} = $n;
$data->{by_list}{$l}{$1}{$months->{$2}} = $n;
}
}
else
{ warn "$l: unrecognized date format: $d";
$err++;
}
}
else
{ $err++;
}
if ($err)
{ warn "Could not find count for $d";
## save the page somewhere
my $temp = $l . "-" . $d;
if ( open(FH, "> $temp_dir$temp") )
{ print FH $page;
close FH;
}
else
{ die "Could not open $temp: $!\n";
}
}
}
}
}
## print out the data
## tab delim'd
my $outfile = $local_dir . 'ml-stats-table.txt';
## as a wiki table
my $wikiout = $local_dir . 'ml-stats-wiki.txt';
open('OUT', '>', $outfile) or die "Could not open $outfile: $!";
open('WIKI','>', $wikiout) or die "Could not open $wikiout: $!";
print OUT "name\t";
print WIKI '{| class="wikitable"' . "\n|-\n! name !! ";
if ($six_month_summary)
{ ## gather up data into six month chunks
foreach my $l (keys %{$data->{by_list}})
{ foreach my $y (keys %{$data->{by_list}{$l}})
{ foreach my $m (keys %{$data->{by_list}{$l}{$y}})
{ if ($m > 6)
{ $data->{by_6_mo}{$l}{$y."-7"} += $data->{by_list}{$l}{$y}{$m};
$data->{all_6_mo}{$y."-7"} += $data->{by_list}{$l}{$y}{$m};
}
else
{ $data->{by_6_mo}{$l}{$y."-1"} += $data->{by_list}{$l}{$y}{$m};
$data->{all_6_mo}{$y."-1"} += $data->{by_list}{$l}{$y}{$m};
}
}
}
}
## table header
print OUT join("\t", sort keys %{$data->{all_6_mo}}) . "\n";
print WIKI join(" !! ", sort keys %{$data->{all_6_mo}}) . "\n";
## now the data
foreach my $name (sort { lc($a) cmp lc($b) } keys %{$data->{by_list}})
{ print OUT "$name\t" . join("\t", map {
if ($data->{by_6_mo}{$name}{$_})
{ $data->{by_6_mo}{$name}{$_}
}
else
{ "0"
}
} sort keys %{$data->{all_6_mo}}) . "\n";
print WIKI "|-\n| $name || " . join(' || ', map {
if ($data->{by_6_mo}{$name}{$_})
{ $data->{by_6_mo}{$name}{$_}
}
else
{ "0"
}
} sort keys %{$data->{all_6_mo}}) . "\n";
}
## totals
print OUT "total\t" . join("\t", map { $data->{all_6_mo}{$_} } sort keys %{$data->{all_6_mo}}) . "\n";
print WIKI "|-\n| total || " . join(' || ', map { $data->{all_6_mo}{$_} } sort keys %{$data->{all_6_mo}}) . "\n";
}
else ## report by month
{
print OUT "name\t";
print WIKI '{| class="wikitable"' . "\n|-\n! name !! ";
## table header
print OUT join("\t", sort keys %{$data->{by_date}}) . "\n";
print WIKI join(" !! ", sort keys %{$data->{by_date}}) . "\n";
foreach my $name (sort { lc($a) cmp lc($b) } keys %{$data->{by_list}})
{ print OUT "$name\t" . join("\t", map {
if ($data->{by_list}{$name}{$_})
{ $data->{by_list}{$name}{$_}
}
else
{ "0"
}
} sort keys %{$data->{by_date}}) . "\n";
print WIKI "|-\n| $name || " . join(' || ', map {
if ($data->{by_list}{$name}{$_})
{ $data->{by_list}{$name}{$_}
}
else
{ "0"
}
} sort keys %{$data->{by_date}}) . "\n";
}
}
print OUT "\n\n";
print WIKI "|}\n\n";
close(OUT);
close(WIKI);
exit(0);