Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 78 lines (66 sloc) 2.049 kB
f3f9f6d @book utilise le perl du path
authored
1 #!/usr/bin/env perl
6fe3748 @book Script pour générer la liste des users de YE 2003 qui ont un compte Act.
authored
2 use strict;
f3f9f6d @book utilise le perl du path
authored
3 use warnings;
6fe3748 @book Script pour générer la liste des users de YE 2003 qui ont un compte Act.
authored
4 use Act::Config;
5 use Act::User;
6 use DBI;
7 use Getopt::Long;
8
9 # options
10 my $usage = << 'EOT';
11 Valid options:
12 --quiet - be quiet
13 --yapc_dsn <dsn> - connection string to the YAPC 2003 DB
14 --yapc_user <user>
15 --yapc_pass <pass>
16 EOT
17
18 # command-line parameters
19 my %conf = ( quiet => 0, );
20 GetOptions( \%conf, "quiet!", "yapc_dsn=s", "yapc_user=s", "yapc_pass=s" )
21 or die $usage;
22
23 die $usage unless $conf{yapc_dsn} && $conf{yapc_user};
24
25 # init the database handle
26 $Request{dbh} = DBI->connect(
27 $Config->database_dsn, $Config->database_user,
28 $Config->database_passwd, { AutoCommit => 0 }
29 )
30 or die "can't connect to database: " . $DBI::errstr;
31
32 my $yapc_dbh
33 = DBI->connect( $conf{yapc_dsn}, $conf{yapc_user}, $conf{yapc_pass} )
34 or die "can't connect to database: " . $DBI::errstr;
35
36 # fetch all users from YAPC
37 my $yapc_sth = $yapc_dbh->prepare( << 'SQL');
38 select * from yapc_user where deleted is not true order by user_id;
39 SQL
40 $yapc_sth->execute;
41
42 my %yapc2act = (
43 user_id => 'yapc_user_id',
44 identifier => 'login',
45 first_name => 'first_name',
46 last_name => 'last_name',
47 nick_name => 'nick_name',
48 email => 'email',
49 );
50
51 my @yapc_users;
52 while ( my $u = $yapc_sth->fetchrow_hashref ) {
53 my $v = Act::User->new();
54 $v->{user_id} = 0;
55 $v->{ $yapc2act{$_} } = $u->{$_} for keys %yapc2act;
56 push @yapc_users, $v;
57 }
58
59 # find possible twins
60 for my $u (@yapc_users) {
61 my $twins = $u->possible_duplicates;
62 for my $v (@$twins) {
63 my $t = scalar @{ $v->talks };
64 print "# YAPC ", user_info($u), "\n", "# ACT ", user_info($v),
65 " ($t talks)\n", $u->{yapc_user_id}, " => ", $v->user_id, "\n";
66 }
67 }
68
69 sub user_info {
70 my ($u) = @_;
871cdbb @book indique le login en plus, pour trouver de nouveaux problemes
authored
71 return ( $u->user_id || $u->{yapc_user_id} ) . ' ['
72 . ( $u->login || $u->{identifier} ) . '] '
6fe3748 @book Script pour générer la liste des users de YE 2003 qui ont un compte Act.
authored
73 . ( $u->full_name || '' ) . " "
74 . ( $u->nick_name ? '(' . $u->nick_name . ')' : '' ) . " <"
75 . ( $u->email || "no email" ) . ">";
76 }
77
Something went wrong with that request. Please try again.