Skip to content
Snippets Groups Projects
Commit 4bf66dd9 authored by Gerhard Gonter's avatar Gerhard Gonter :speech_balloon:
Browse files

a few small repairs

parent dec19837
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ use parent 'Redmine::DB'; ...@@ -6,6 +6,7 @@ use parent 'Redmine::DB';
# use Redmine::DB::Project; # use Redmine::DB::Project;
my $show_query= 0;
my $show_fetched= 0; my $show_fetched= 0;
sub connect sub connect
...@@ -50,14 +51,20 @@ sub get_all_x ...@@ -50,14 +51,20 @@ sub get_all_x
my @v= (); my @v= ();
if (defined ($where)) if (defined ($where))
{ {
print "where: ", main::Dumper ($where); print "where: ", main::Dumper ($where) if ($show_query);
$ss .= ' WHERE ' . shift (@$where); $ss .= ' WHERE ' . shift (@$where);
@v= @$where; @v= @$where;
} }
print "ss=[$ss]\n";
if ($show_query)
{
print "ss=[$ss]";
print ' vars: ', join (',', @v) if (@v);
print "\n";
}
my $sth= $dbh->prepare($ss) or print $dbh->errstr; my $sth= $dbh->prepare($ss) or print $dbh->errstr;
print "sth=[$sth]\n"; # print "sth=[$sth]\n";
$sth->execute(@v); $sth->execute(@v);
my $t= $self->table($table); my $t= $self->table($table);
...@@ -94,19 +101,20 @@ sub get_project_members ...@@ -94,19 +101,20 @@ sub get_project_members
=cut =cut
sub get_members sub pcx_members
{ {
my $self= shift; my $self= shift;
my $proj_id= shift; my $proj_id= shift;
my $res= $self->table('x_sync'); my $res= $self->table('pcx');
my $proj= $self->get_all_x ('projects', [ 'id=?', $proj_id ]); my $proj= $self->get_all_x ('projects', [ 'id=?', $proj_id ]);
my $members= $self->get_all_x ('members', [ 'project_id=?', $proj_id ]); my $members= $self->get_all_x ('members', [ 'project_id=?', $proj_id ]);
$res->{'project'}= $proj; $res->{'project'}= $proj;
$res->{'members'}= $members; $res->{'members'}= $members;
print "proj: ", main::Dumper($proj); # print "proj: ", main::Dumper($proj);
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# check for members and users # check for members and users
...@@ -125,7 +133,7 @@ sub get_members ...@@ -125,7 +133,7 @@ sub get_members
if (@missing_users) if (@missing_users)
{ {
print "missing users: [", join (' ', @missing_users), "]\n"; # print "missing users: [", join (' ', @missing_users), "]\n";
my $in= 'id IN ('. join(',', map { '?' } @missing_users) . ')'; my $in= 'id IN ('. join(',', map { '?' } @missing_users) . ')';
# $show_fetched= 1; # $show_fetched= 1;
$self->get_all_x ('users', [ $in, @missing_users ]), $self->get_all_x ('users', [ $in, @missing_users ]),
...@@ -134,12 +142,12 @@ sub get_members ...@@ -134,12 +142,12 @@ sub get_members
$res; $res;
} }
sub get_wiki sub pcx_wiki
{ {
my $self= shift; my $self= shift;
my $proj_id= shift; my $proj_id= shift;
my $res= $self->table('x_sync'); my $res= $self->table('pcx');
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# check for wiki stuff # check for wiki stuff
...@@ -159,7 +167,8 @@ sub get_wiki ...@@ -159,7 +167,8 @@ sub get_wiki
foreach my $wiki_id (@wiki_ids) foreach my $wiki_id (@wiki_ids)
{ {
my $wiki_pages= $self->get_all_x ('wiki_pages', [ 'wiki_id=?', $proj_id ]); my $wiki_pages= $self->get_all_x ('wiki_pages', [ 'wiki_id=?', $proj_id ]);
print "wiki_id=[$wiki_id] wiki_pages: ", main::Dumper ($wiki_pages); $res->{'wiki_pages'}->{$wiki_id}= $wiki_pages;
# print "wiki_id=[$wiki_id] wiki_pages: ", main::Dumper ($wiki_pages);
} }
} }
......
...@@ -32,6 +32,8 @@ use Redmine::DB::MySQL; ...@@ -32,6 +32,8 @@ use Redmine::DB::MySQL;
# yeah, this should be in a config file, but # yeah, this should be in a config file, but
my $setup_file; my $setup_file;
# this structure ($setup) resembles something like a "context"
my $setup= my $setup=
{ {
'src' => 'src' =>
...@@ -87,13 +89,13 @@ sub usage ...@@ -87,13 +89,13 @@ sub usage
exit (0); exit (0);
} }
if ($op_mode eq 'usage') { usage(); } if ($op_mode eq 'usage') { usage(); }
elsif ($op_mode eq 'prep') elsif ($op_mode eq 'prep')
{ {
my $dst= read_configs($setup, 'dst'); my $dst= read_configs($setup, 'dst');
prepare_sync_table ($dst); prepare_sync_table ($dst);
} }
elsif ($op_mode eq 'sdp') elsif ($op_mode eq 'sdp') # sdp: show destination intance's projects
{ {
my $dst= read_configs($setup, 'dst'); my $dst= read_configs($setup, 'dst');
...@@ -104,14 +106,18 @@ elsif ($op_mode eq 'sync') ...@@ -104,14 +106,18 @@ elsif ($op_mode eq 'sync')
{ {
my $src= read_configs($setup, 'src'); my $src= read_configs($setup, 'src');
my $dst= read_configs($setup, 'dst'); my $dst= read_configs($setup, 'dst');
# my $x_u= $src->get_all_users();
# print "setup: ", Dumper ($setup); # print "setup: ", Dumper ($setup);
foreach my $sp (@{$setup->{'sync_projects'}}) foreach my $sp (@{$setup->{'sync_projects'}})
{ {
my $proj_id= $sp->{'src_proj'};
print "sp: ", Dumper ($sp); print "sp: ", Dumper ($sp);
my $sx= $src->get_project_members ($sp->{'src_proj'}); $src->pcx_members ($proj_id);
print "sx: ", Dumper ($sx); my $pcx= $src->pcx_wiki ($proj_id);
print "pcx: ", Dumper ($pcx);
# print "src: ", Dumper ($src);
} }
} }
elsif ($op_mode eq 'diag') elsif ($op_mode eq 'diag')
...@@ -127,7 +133,7 @@ elsif ($op_mode eq 'diag') ...@@ -127,7 +133,7 @@ elsif ($op_mode eq 'diag')
# print "src_usr: ", Dumper ($src_usr); # print "src_usr: ", Dumper ($src_usr);
# print "src: ", Dumper ($src); # print "src: ", Dumper ($src);
# my $src_members= $src->get_project_members (170); # my $src_members= $src->get_project_members (... some project id ...);
# print "src_members: ", Dumper ($src_members); # print "src_members: ", Dumper ($src_members);
...@@ -183,5 +189,7 @@ CREATE TABLE `syncs` ...@@ -183,5 +189,7 @@ CREATE TABLE `syncs`
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
EOX EOX
# NOTE: for some reason, this can't be sent to the database, maybe/probably I'm missing something...
print "perform this on the database\n", "--- 8< ---\n", $ss, "--- >8 ---\n"; print "perform this on the database\n", "--- 8< ---\n", $ss, "--- >8 ---\n";
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment