From b57949f88c9522f2c0ac81c7596d51327c7f028a Mon Sep 17 00:00:00 2001 From: janw Date: Fri, 7 Mar 2008 10:17:11 +0000 Subject: [PATCH] Better Performance when inserting in db. Add FAIstate to db. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9426 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 2e43b6fc3..2251e9f7a 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -127,7 +127,7 @@ our $fai_server_tn = "fai_server"; my $fai_server_file_name; our @fai_server_col_names = ('timestamp', 'server', 'release', 'tag'); our $fai_release_tn = "fai_release"; -our @fai_release_col_names = ('timestamp', 'release', 'class', 'type'); +our @fai_release_col_names = ('timestamp', 'release', 'class', 'type', 'state'); # holds all packages available from different repositories our $packages_list_db; @@ -1279,6 +1279,7 @@ sub create_fai_release_db { if($mesg->{'resultCode'} == 0 && $mesg->count != 0) { # Walk through all possible FAI container ou's + my @sql_list; foreach my $ou (@{$mesg->{entries}}) { my $tmp_classes= resolve_fai_classes($ou->dn); if(defined($tmp_classes)) { @@ -1286,18 +1287,22 @@ sub create_fai_release_db { if(@tmp_array) { foreach my $entry (@tmp_array) { if(defined($entry) && ref($entry) eq 'HASH') { - $fai_server_db->add_dbentry( { - table => $table_name, - primkey => ['release', 'class', 'type'], - release => $entry->{'release'}, - class => $entry->{'class'}, - type => $entry->{'type'} - } ); + my $timestamp= &get_time(); + my $sql= + "INSERT INTO $table_name " + ."(timestamp, release, class, type, state) VALUES (" + .$timestamp."," + ."'".$entry->{'release'}."'," + ."'".$entry->{'class'}."'," + ."'".$entry->{'type'}."'," + ."'".$entry->{'state'}."')"; + push @sql_list, $sql; } } } } } + $fai_server_db->exec_statementlist(\@sql_list); } daemon_log("Done with creating fai_release_db",4); } @@ -1325,11 +1330,13 @@ sub get_fai_release_entries { } } else { my $types = get_fai_types($tmp_classes->{$entry}); + my $state = get_fai_state($tmp_classes->{$entry}); push @result, { 'class' => $entry, 'type' => $types, 'release' => $parent, + 'state' => $state, }; } } @@ -1351,6 +1358,22 @@ sub get_fai_types { return $result; } +sub get_fai_state { + my $result = ""; + my $tmp_classes = shift || return $result; + + foreach my $type(keys %{$tmp_classes}) { + if(defined($tmp_classes->{$type}[0])) { + $result = $tmp_classes->{$type}[0]; + + # State is equal for all types in class + last; + } + } + + return $result; +} + sub resolve_fai_classes { my $result; my $fai_base= shift; -- 2.30.2